Is there any way to hash a string, and un-hash it later?
For example, I want to hash an email address to make a unique link, and retrieve the email address when the link is visited.
It's more about obfuscation than hashing, as you can see.
Is there any way to hash a string, and un-hash it later?
For example, I want to hash an email address to make a unique link, and retrieve the email address when the link is visited.
It's more about obfuscation than hashing, as you can see.
You cannot hash and unhash a string but can use base64_encode and base64_decode to do a similar thing:
<?php
$str = 'This is an encoded string';
echo base64_encode($str);
?>
The above example will output:
VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==
You can decode it:
<?php
$str = 'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==';
echo base64_decode($str);
?>
The above example will output:
This is an encoded string
As in the PHP.net manual: