0
我試圖加密/從form.I解密數據了,可以幫助我做類從:Encryped /解密數據的PHP
https://github.com/o/crypt-php
的加密工作,但是當我嘗試解密它給我一個錯誤說:
未捕獲的異常「異常」有消息「給定的數據不會出現與地穴加密」
我的代碼:
//for encrypt(this works)
require_once("Crypt.php");
$crypt = new Crypt;
$crypt->setKey('keykeykeyy');
$password = $_POST['password'];
$crypt->setData($password);
$encrypted = $crypt->encrypt();
//for decrypt almost the same thing
$password = $_POST['password'];
$crypt->setData($password);
$decrypted = $crypt->decrypt();
什麼問題?
請問'$設置數據_POST ['密碼']'真的有加密的數據呢?調試的第一步應該是打印出值。 – Devon
如果這是一個實際的用戶密碼,你不應該使用加密,你應該使用散列。密碼不應該被解密。 PHP內置了處理此功能的功能:[password_hash()](http://php.net/manual/en/function.password-hash.php) – Devon