If you encode it with base64, but anyone can decode it easily. How sensitive is your hash?
str = "The quick brown fox jumps over the lazy dog";
b64 = btoa(unescape(encodeURIComponent(str)));
str = decodeURIComponent(escape(window.atob(b64)));
The output will be VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==
If you are using PHP you would just base64_encode() and base64_decode() to handle. You can make for example a input hidden with encoded value and then just get it's val and use the last line i gave you.
Base64 PHP http://php.net/manual/en/function.base64-encode.php and base64 JAVASCRIPT https://developer.mozilla.org/pt-BR/docs/Web/API/WindowBase64/atob . Or you could encrypt it's contents then uncrypt it server side. Heres a little class to encrypt/decrypt data (PHP):
<?php
namespace Company\Security;
/*
* @description: Simple class to wrap crypt function calls
* @author: Marco A. Simao
*/
class Crypto {
/*
* returns encrypted data with iv appended at the begining of the string
*/
public static function encrypt($data, $key)
{
$iv = openssl_random_pseudo_bytes(16);
$c = openssl_encrypt($data, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $iv);
return $iv . $c;
}
/*
* returns decrypted data. Expects 16 first bytes of data to be iv table.
*/
public static function decrypt($data, $key)
{
return openssl_decrypt(substr($data, 16), 'AES-128-CBC', $key, OPENSSL_RAW_DATA, substr($data, 0, 16));
}
}
And you would need a decrypt in Javascript like: How to use the Web Crypto API to decrypt a file created with OpenSSL?