Hi Everyone,
I've a big problem with the iEncryption library.
I need to bring this vb.net code on B4I.
This is my B4I Sub and it doesn't give me the right encrypted bytes, which are returned correctly in .NET.
Please help me, i've to solve this problem if i want to keep my job safe
I've a big problem with the iEncryption library.
I need to bring this vb.net code on B4I.
B4X:
Dim AES As New System.Security.Cryptography.RijndaelManaged
Public Function Codifica(ByVal stringToEncrypt As String, Optional ByVal key() As Byte = Nothing) As String
Dim encrypted As String = ""
Try
If key IsNot Nothing Then AES.Key = key
AES.KeySize = 128
AES.BlockSize = 128
AES.Padding = Security.Cryptography.PaddingMode.Zeros
AES.Mode = Security.Cryptography.CipherMode.CBC
If AES.Key.Length > 0 Then
Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateEncryptor
Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(stringToEncrypt)
encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
'For temp2 As Byte = 0 To Buffer.Length - 1
' Debug.Print(String.Format("{0} - {1}", Buffer(temp2), Hex(Buffer(temp2))))
'Next
End If
Catch ex As Exception
Debug.Print(ex.Message)
End Try
Return encrypted
End Function
This is my B4I Sub and it doesn't give me the right encrypted bytes, which are returned correctly in .NET.
B4X:
Private Sub GetXpKeys()
Dim bytes2Crypt() As Byte = Array As Byte(TCPIP_KEY_REQUEST)
Dim msg2Send() As Byte = iAes.Encrypt2(bytes2Crypt, pKeys, "AES", Null, iAes.OPTION_PKCS7Padding)
SendMessage(msg2Send)
End Sub
Please help me, i've to solve this problem if i want to keep my job safe