Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
EditText2.Text = MyEncryptText(EditText1.Text, ForestGumpsPassword)
Log("Encypted: " & EditText2.text)
Log("Decypted: " & myDecryptText(EditText2.text, ForestGumpsPassword))
EditText3.Text = ""
' write result to a file to see if windows can decypt it at the other end
File.WriteString(rp.GetSafeDirDefaultExternal(""), $"${EditText1.Text}.txt"$, EditText2.text)
End Sub
Sub Button2_Click
EditText3.Text = myDecryptText(EditText2.text, ForestGumpsPassword)
Log(EditText3.Text)
End Sub
Sub MyEncryptText(text As String, password As String) As String
Dim su As StringUtils
Dim c As B4XCipher
Return su.EncodeBase64(c.Encrypt(text.GetBytes("utf8"), password))
' exploded version
' A - Turn the original text into a array of bytes
' B - Encrypt that array into another array of btyes
' C - Convert the encrypted array of bytes into a base64 string and return it
' Dim OriginalTextToByteArray() As Byte = text.GetBytes("utf8")
' Dim ReturnedEncryptedByteArray() As Byte = c.Encrypt(OriginalTextToByteArray, password)
' Return su.EncodeBase64(ReturnedEncryptedByteArray)
End Sub
Sub myDecryptText(text As String, Password As String) As String
Dim su As StringUtils
Dim c As B4XCipher
Dim b() As Byte = c.Decrypt(su.DecodeBase64(text), Password)
Return BytesToString(b, 0, b.Length, "utf8")
' exploded version
' A - Decode the text from base64 into a byte array
' B - decrypt that byte array
' C - convert the byte array into a string and return it
' Dim OriginalEncryptedStringAsByteArray() As Byte = su.DecodeBase64(text)
' Dim OriginalDecryptedStringAsBtyeArray() As Byte = c.Decrypt(OriginalEncryptedStringAsByteArray, Password)
' Return BytesToString(OriginalDecryptedStringAsBtyeArray,0,OriginalDecryptedStringAsBtyeArray.Length, "utf8")
End Sub