I thought this looked really interesting for a small password storage system I have planned for ages.
Simply to encypt a text file with the password information, and decrypt as required.
Example below returns an error on compiling. I have tried different keys, including the one in the original post.
I see a couple of purple underline messages in the B4J editor. e.g. bld.Algorithm = ac.AES indicates a forced string conversion.
I have put the Alice.jar and Alice.xml into my "Additional Libraries/B4J" folder.
What have I missed?
Example of the code.
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private alice As Alice
Private ac As AliceConstants
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
Dim Foldername As String = "My file location"
Dim bld As AliceContextBuilder
bld.Initialize("")
bld.Algorithm = ac.AES
bld.Mode = ac.CTR
alice.Initialize("MyAlice",bld.build)
' Encrypt file
alice.encryptFile2(Foldername,"Alice.txt", Foldername, "AliceOut.txt", "FGERHZXCG434TRWR")
MainForm.Show
End Sub
Error message:
encryptFile()
Error occurred on line: 23 (Main)
java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1039)
at javax.crypto.Cipher.implInit(Cipher.java:805)
at javax.crypto.Cipher.chooseProvider(Cipher.java:864)
at javax.crypto.Cipher.init(Cipher.java:1396)
at javax.crypto.Cipher.init(Cipher.java:1327)
at com.rockaport.alice.Alice.encrypt(Alice.java:229)
at de.donmanfred.Alicewrapper.encryptFile2(Alicewrapper.java:105)
at b4j.example.main._appstart(main.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)