加密 賬號登入密碼傳輸加密

2021-09-28 12:43:09 字數 1391 閱讀 8560

在實際使用過程中,使用者登入時密碼如果明文,存在被黑客竊取的高危風險。通過https傳輸加密和密碼傳輸加密 這兩種方式,來防止賬號登入過程的資訊洩露風險。

密碼傳輸加密,我採取aes對稱加密,頁面js裡面加密,後台接受密文,再解密還原密碼。更嚴謹的是再加鹽,這裡不做深究。

#加密密碼

function encrypt(data) ).tostring();

}function login()

byte plaintext = new byte[plaintextlength];

system.arraycopy(databytes, 0, plaintext, 0, databytes.length);

secretkeyspec keyspec = new secretkeyspec(key.getbytes(), "aes");

ivparameterspec ivspec = new ivparameterspec(iv.getbytes());

cipher.init(cipher.encrypt_mode, keyspec, ivspec);

byte encrypted = cipher.dofinal(plaintext);

return new base64().encodetostring(encrypted);

} catch (exception e)

} /**

* 解密方法

* @param data 要解密的資料

* @param key 解密key

* @param iv 解密iv

* @return 解密的結果

* @throws exception

*/public static string desencrypt(string data, string key, string iv) throws exception catch (exception e)

} /**

* 使用預設的key和iv加密

* @param data

* @return

* @throws exception

*/public static string encrypt(string data) throws exception

/*** 使用預設的key和iv解密

* @param data

* @return

* @throws exception

*/public static string desencrypt(string data) throws exception

}

傳輸密碼加密方式

雜湊雜湊雜湊雜湊並不能算是嚴格意義上的加密技術,因此我把它稱為通用意義上的加密技術,雜湊雜湊的通用定義是 通過一些不可逆的雜湊演算法將原本的明文內容轉化為雜湊後的密文內容。由於雜湊演算法幾乎不可逆,因此攻擊者幾乎無法通過密文猜測到對應的明文內容。通過這種機制做到加密控制,典型的演算法由我們之前耳熟能...

php加密登入 PHP安全登入 密碼加密

以下是要實施安全登入的登入系統 main login.php username password checklogin.php ob start host localhost host name username root mysql username password mysql password...

使用者登入密碼加密

密碼加密 param pwd 原始密碼 param salt 鹽值 return public string encryptedpassword string pwd,string salt 生成鹽 string salt new securerandomnumbergenerator nextby...