Hi,
I have a problem when try to get the same results on B4J and .NET using the agraham Encryption library, if somebody can help me with this i will really appreciate.
Here is my B4J code:
And here is my .NET code:
Thank you so much.
I have a problem when try to get the same results on B4J and .NET using the agraham Encryption library, if somebody can help me with this i will really appreciate.
Here is my B4J code:
B4X:
' This one return: BBGWT0W/Tw8=
Public Sub Encrypt As String
Dim su As StringUtils
Dim c As Cipher
c.Initialize("DESEDE/CBC/PKCS5Padding")
c.InitialisationVector = su.DecodeBase64("yKoS+M16uDU=")
Dim Kg As KeyGenerator
Kg.Initialize("DESEDE")
Kg.KeyFromBytes(su.DecodeBase64("QzWZyG+DImE="))
Return su.EncodeBase64(c.Encrypt(su.DecodeBase64("1"), Kg.key, True))
End Sub
And here is my .NET code:
B4X:
' this one fails,
Function Encrypt() As String
Dim result As String = ""
Dim data As Byte() = New UTF8Encoding(False).GetBytes("1")
Dim des As New TripleDESCryptoServiceProvider()
des.IV = Convert.FromBase64String("yKoS+M16uDU=")
des.Key = Convert.FromBase64String("QzWZyG+DImE=") ' => here is the problem, key is to short
result = Convert.ToBase64String(des.CreateEncryptor().TransformFinalBlock(data, 0, data.Length))
des.Clear()
Return result
End Function
Thank you so much.
Last edited: