Android Question En- and Decrypting a string

prokli

Active Member
Licensed User
Longtime User
Hi everybody!
I just want to en/decrypt a simple string. For that I copied SS_AESEncryption.jar and SS_AESEncryption.xml to the
location where I stored all other external and additional libraries.
Even this simlpe declaration:

Declaration:
Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Public EncDec As AESEncryption
    '+++++++++++++++++++++++++++++++++++++++

fires an error: "libraries\encrption.jar" not found
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Don't.

Add a reference to B4XEncryption:
B4X:
Dim cipher As B4XCipher
Dim encrypted() As Byte = cipher.Encrypt("your simple string".GetBytes("utf8"), "your complex password")
'now test
Dim decrypted() As Byte = cipher.Decrypt(encrypted, "your complex password")
Log(BytesToString(decrypted, 0, decrypted.Length, "utf8"))

It is cross platform. In B4J you need to download bouncycastle and add a reference with #AdditionalJar: https://www.b4x.com/android/forum/threads/share-encrypted-data-with-b4a.35482/#content
 
Upvote 0
Top