如果您使用base64編碼,但任何人都可以輕鬆解碼。你的散列有多敏感?
str = "The quick brown fox jumps over the lazy dog";
b64 = btoa(unescape(encodeURIComponent(str)));
str = decodeURIComponent(escape(window.atob(b64)));
輸出將是VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw ==
如果你正在使用PHP你只BASE64_ENCODE()和BASE64_DECODE()來處理。例如,你可以使用編碼值隱藏輸入,然後獲取它的val值並使用我給你的最後一行。
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。或者你可以加密它的內容然後解密服務器端。下面有一個小類加密/解密數據(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));
}
}
而且你需要在JavaScript中解密,如:How to use the Web Crypto API to decrypt a file created with OpenSSL?
只能混淆它,而不是真正的「隱藏」 – haim770
您可以使用'CryptoJS':https://stackoverflow.com/questions/18279141/javascript-string-encryption-and-decryption –
你需要像[RSA](http://www.ohdave.com/rsa/)這樣的非對稱算法。 – ceving