#AdditionalJar: bcprov-jdk15on-154
Sub Process_Globals
End Sub
Sub AppStart (Args() As String)
Dim p As String = "123456"
Dim s As String = "top secret"
Dim enc As String = Encrypt(s, p)
Log(enc)
Dim dec As String = Decrypt(enc, p)
Log(dec)
End Sub
Private Sub Encrypt (Text As String, Password As String) As String
Dim c As B4XCipher
Dim b() As Byte = c.Encrypt(Text.GetBytes("utf8"), Password)
Dim su As StringUtils
Return su.EncodeBase64(b)
End Sub
Private Sub Decrypt(EncryptedText As String, Password As String) As String
Dim c As B4XCipher
Dim su As StringUtils
Dim enc() As Byte = su.DecodeBase64(EncryptedText)
Dim dec() As Byte = c.Decrypt(enc, Password)
Return BytesToString(dec, 0, dec.Length, "utf8")
End Sub