can please me php script decrypt value in php being created in powershell using rijndael key.
the powershell script i've used create below
[reflection.assembly]::loadfile('c:\windows\microsoft.net\framework\v2.0.50727\system.web.dll') | out-null $xcadmpass = "cloudytest" $r = new-object system.security.cryptography.rijndaelmanaged # use rijndael symmetric key encryption $c = $r.createencryptor((1..16), (1..16)) # set key , initialisation vector 128-bytes each of (1..16) $ms = new-object io.memorystream $cs = new-object security.cryptography.cryptostream $ms,$c,"write" # target data stream, transformation, , mode $sw = new-object io.streamwriter $cs $sw.write($xcadmpass) # write string through crypto stream memory stream $sw.close() $cs.close() $ms.close() $r.clear() [byte[]]$result = $ms.toarray() # byte array encrypted memory stream $encpass = [convert]::tobase64string($result) the encrypted value yd3/yegk64jj2lui20mo8q==
i've tried using mcrypt_decrypt can't figure out correct way original text.
this i've tried
$input = "yd3/yegk64jj2lui20mo8q=="; $key = "12345678910111213141516"; $data = base64_decode($input); $iv = substr($data, 0, mcrypt_get_iv_size(mcrypt_rijndael_128, mcrypt_mode_cbc)); $decrypted = rtrim( mcrypt_decrypt( mcrypt_rijndael_128, $key, substr($data, mcrypt_get_iv_size(mcrypt_rijndael_128, mcrypt_mode_cbc)), mcrypt_mode_cbc, $iv ), "\0" ); i'm going wrong somewhere appreciated.
thanks this. i'll show final code else runs similar issues.
powershell
[reflection.assembly]::loadfile('c:\windows\microsoft.net\framework\v2.0.50727\system.web.dll') | out-null $xcadmpass = "cloudytest" $r = new-object system.security.cryptography.rijndaelmanaged # use rijndael symmetric key encryption $c = $r.createencryptor((1..16), (1..16)) # set key , initialisation vector 128-bytes each of (1..16) $ms = new-object io.memorystream $cs = new-object security.cryptography.cryptostream $ms,$c,"write" # target data stream, transformation, , mode $sw = new-object io.streamwriter $cs $sw.write($xcadmpass) # write string through crypto stream memory stream $sw.close() $cs.close() $ms.close() $r.clear() [byte[]]$result = $ms.toarray() # byte array encrypted memory stream $encpass = [convert]::tobase64string($result) php
$input = "yd3/yegk64jj2lui20mo8q=="; $iv = "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"; $key = "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10"; $data = base64_decode($input); $decrypted = rtrim( mcrypt_decrypt( mcrypt_rijndael_128, $key, $data, mcrypt_mode_cbc, $iv ), "\0" ); echo $decrypted;
Comments
Post a Comment