decrypting using (mcrypt with php) from a vb.net encrypted source

php_hore

Newcomer
Joined
Jul 26, 2003
Messages
1
Guru's help !!!

I am working on a project that uses .net to encrypt form data and save it into a xml file (base64 encoded).

I have 3 methods of encryption and decryption working fine in .net (tripledes,rijandeal128, 256)

the problem is I'm needing to decrypt it server side using php by using the same KEY and IV that I used to encrypt the data with.

does anyone know how to use the same byte array's in php?
all the sources and examples I've seen are $key="secret pass"

which is fine but .net changes the "secret pass" into a byte array before passing the key. so when I use "secret pass" php side it is not the same.

example of what I'm doing (sort of):

vb.net code to encrypt:
Private key() As Byte = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}
Private iv() As Byte = {65, 110, 68, 26, 69, 178, 200, 219}

Dim tdesProvider As TripleDESCryptoServiceProvider = New TripleDESCryptoServiceProvider()
Dim cryptoTransform As ICryptoTransform = tdesProvider.CreateEncryptor(Me.key, Me.iv)
blah...blah...
Return Convert.ToBase64String(result)

PHP server side code to decrypt:
$key = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24);/?
$IV = array(65, 110, 68, 26, 69, 178, 200, 219);/?

$data = base64_decode("uvoEuC0Ap6ehdrp9Pn6yvQ==");
$iv_size = mcrypt_get_iv_size(MCRYPT_TripleDES, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);

$crypttext = mcrypt_decrypt(MCRYPT_TripleDES, $key, $data, MCRYPT_MODE_ECB, $iv);
echo $crypttext."\n";

~any help would be greatly appreciated!
 
Back
Top