Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim incsms As String
Dim outsms As String
outsms = Encrypt("hello how are you doing on such a fine day I hope you are enjoying the sun.")
incsms = Decrypt (outsms)
ToastMessageShow(outsms,True)
ToastMessageShow(incsms,True)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Encrypt(dataToEncrypt As String ) As String
Dim kg As KeyGenerator
Dim c As Cipher
Dim B64 As Base64
Dim Bconv As ByteConverter
Dim data(0) As Byte
Dim iv(0) As Byte
Dim p As String
Dim md As MessageDigest
iv = Array As Byte(211, 22, 233, 24, 55, 166, 7, 88) ' 16 bytes for AES
c.Initialize("DESEDE/CBC/PKCS5Padding")
c.InitialisationVector = iv
kg.Initialize("DESEDE")
'kg.KeyFromBytes(Bconv.StringToBytes("1234567890123456","ASCII"))
p = "passwrd"
kg.KeyFromBytes(md.GetMessageDigest(p.GetBytes("UTF8"), "MD5"))
data = Bconv.StringToBytes(dataToEncrypt, "ASCII")
data = c.Encrypt(data, kg.Key, True)
Return B64.EncodeBtoS(data, 0, data.Length)
End Sub
Sub Decrypt(encryptedData As String ) As String
Dim kg As KeyGenerator
Dim c As Cipher
Dim B64 As Base64
Dim Bconv As ByteConverter
Dim data(0) As Byte
Dim iv(0) As Byte
Dim p As String
Dim md As MessageDigest
iv = Array As Byte(211, 22, 233, 24, 55, 166, 7, 88) ' 16 bytes for AES
c.Initialize("DESEDE/CBC/PKCS5Padding")
c.InitialisationVector = iv
kg.Initialize("DESEDE")
'kg.KeyFromBytes(Bconv.StringToBytes("1234567890123456","ASCII"))
p = "password"
kg.KeyFromBytes(md.GetMessageDigest(p.GetBytes("UTF8"), "MD5"))
data = B64.DecodeStoB(encryptedData)
data = c.Decrypt(data, kg.Key, True)
Return Bconv.StringFromBytes(data, "ASCII")
End Sub