Hello,
I want to encrypt raw binary data with cipher.
However, when decrypting the encrypted data, additional bytes are added to the result of the decryption.
The code below shows the problem:
What am I doing wrong?
I want to encrypt raw binary data with cipher.
However, when decrypting the encrypted data, additional bytes are added to the result of the decryption.
The code below shows the problem:
B4X:
Dim lp As Int
Dim pw As String= "password"
Dim unencrypted(16) As Byte
For lp= 0 To 15
unencrypted(lp)= lp
Next
'encrypt the data
Dim encryptor As Cipher
Dim encrypted() As Byte= encryptor.Encrypt(unencrypted, pw)
'verify output
Dim decryptor As Cipher
Dim decrypted() As Byte= decryptor.Decrypt(encrypted, pw)
If unencrypted.Length <> decrypted.Length Then
LogColor("unencrypted.Length= " & unencrypted.Length, Colors.Blue)
LogColor("decrypted.Length= " & decrypted.Length, Colors.Blue)
Else
For lp= 0 To unencrypted.Length-1
If unencrypted(lp) <> decrypted(lp) Then
LogColor(lp & " => unencrypted(lp) <> decrypted(lp)", Colors.Blue)
End If
Next
End If
What am I doing wrong?