views:

247

answers:

3

Hello guys,

Please I need your help, Here is my encryption codes in PHP, it works fine but I don't know how to decrypt it in PHP. I need to get the actual value back. I have similar code in c# and I was able to get the same results. But I need to decrypt the value.

<?php 

$DATA= 'james' ;
$KEY= 'moveme'; 

$hash = hash_hmac("sha256", utf8_encode($DATA), utf8_encode($KEY), false); 

echo $hash; 

?>
+1  A: 

If you need to be able to encrypt and decrypt information, read up on the mcrypt functions.

Ronald D. Willis
yes , I want it to work in both c# and php
james
+8  A: 

Hi,

hash_hmac is a hashing function, not a cryptographic one. You won't be able to decrypt it.

You should use the Mcrypt module instead.

Patrick MARIE
+1  A: 

The SHA-256 hash function is a hash function, it is not bijective. You cannot get your value back, neither in PHP nor in C#. Would be interesting to see this "working" C# code.

GodsBoss
Here is another question http://stackoverflow.com/questions/2244796/encryption-and-decryption-that-work-for-both-c-and-php
james