[英]How can I encrypt a string using public key to generate a static string rather than a dynamic one in php?
I am trying to encrypt a string using a public key but each time I get a new string. 我正在尝试使用公共密钥对字符串进行加密,但是每次我得到一个新字符串时,我都会这样做。 Any workarounds to getting a static string?
任何获取静态字符串的解决方法?
Here is my code 这是我的代码
$publicKey = openssl_pkey_get_public(file_get_contents("file://C:/Users/nick/Dropbox/wamp/www/samples/mycert.cer"));
$plaintext = "Matr!x12";
openssl_public_encrypt($plaintext, $encrypted, $publicKey, OPENSSL_PKCS1_PADDING);
echo base64_encode($encrypted);
Well, obviously SSL encryption generates different results each time it's involved for security reasons. 好吧,显然出于安全原因,每次涉及SSL加密都会产生不同的结果。 If you for whatever reason you need to have identical results multiple times you cannot use "real encryption".
如果出于某种原因需要多次获得相同的结果,则不能使用“真实加密”。 Maybe just use MD5 or some other hash function but be aware that you cannot get secrets that cannot be decrypted (with enough effort).
也许只是使用MD5或其他某种哈希函数,但要注意,您无法获得无法解密的机密信息(需要付出足够的努力)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.