C# Rfc2898DeriveBytes to PHP -
i'm trying adapt following function c# php , can't work. i've searched other threads, couldn't find right answer solve problem.
public static string decrypt(string encryptedtext) { byte[] bytes = encoding.ascii.getbytes("hello"); byte[] buffer = convert.frombase64string(encryptedtext); byte[] rgbkey = new rfc2898derivebytes("world", bytes).getbytes(0x20); icryptotransform transform = new rijndaelmanaged { mode = ciphermode.cbc }.createdecryptor(rgbkey, bytes); memorystream stream = new memorystream(buffer); cryptostream stream2 = new cryptostream(stream, transform, cryptostreammode.read); byte[] buffer4 = new byte[buffer.length]; int count = stream2.read(buffer4, 0, buffer4.length); stream.close(); stream2.close(); return encoding.utf8.getstring(buffer4, 0, count); }
any appreciated. thanks!
my php code far:
<?php $key = hash_pbkdf2('sha1', 'world', 'hello', 1000, 32); $decrypted = mcrypt_decrypt( mcrypt_rijndael_128, $key, 'very long encrypted string', mcrypt_mode_cbc, 'world'); ?>
Comments
Post a Comment