Hi all
Am trying to encrypt an xml file in php then decrypt using vb.net.
We use 3des on php to encrypt , in this case the encrypted string is :
"nM+uUETBa2NY2jfUtmv5lJtiyBp2b8Wvv4lWqtr82Wpv9+fCugOGIgDBjlKhQXkeMJEYvdBMkZBh9FSQyVizTWxUzmWE5VBrWQdYniupC6jwxp46+b5/D5LyJM08I7KXCshL0Y1Mw9EX1bW8642qV/KmWqeg3viYHs9MsHxPrCLMl6k/dzGyGZop5OL3M3ApsvV8ftJjHwLTU4Yq9QROwr45qkTG45Uq+JbgFdLuz4qgnd2DFi3QZJsG4ZwBewSljnVGRsse2wBQxyJuwVskckeFjob2P715hIrAQCzUf7c="
The key is "andy"
then i use the below vb.net function to decrypt..
The function fails with a message "Bad Data", any ideas on how to tune
it up to decrypt this?
Public Function Decrypting(ByVal [Source] As String, ByVal Key As
String) As String
' convert from Base64 to binary
Dim bytIn As Byte() =
System.Convert.FromBase64String([Source])
' create a MemoryStream with the input
Dim ms As New System.IO.MemoryStream(bytIn, 0,
bytIn.Length)
Dim bytKey As Byte() = GetLegalKey(Key)
' set the private key
mobjCryptoService.Key = bytKey
mobjCryptoService.IV = bytKey
' create a Decryptor from the Provider Service instance
Dim encrypto As ICryptoTransform =
mobjCryptoService.CreateDecryptor()
' create Crypto Stream that transforms a stream using the
decryption
Dim cs As New CryptoStream(ms, encrypto,
CryptoStreamMode.Read)
' read out the result from the Crypto Stream
Dim sr As New System.IO.StreamReader(cs)
Return sr.ReadToEnd()
End Function 'Decrypting
|