關於前端數據加密

什麼是前端加密php

  前端加密就是在客戶端對用戶要提交的內容進行加密,從而下降服務器端的壓力。前端

爲何要進行前端加密數據庫

   進行前端加密值後,要對密碼進行破譯和破解,則須要在客戶端方面消耗更多的資源,延長了破解時間,從而得到了更高的安全性。後端

 

前端加密方式:瀏覽器

  • https,安全性高。證書認證,一種是來自於證書頒發機構;一種是本身生成證書,但須要瀏覽器添加信任;成本高。
  • post以前,經過js對密碼進行加密。前端js:md5+salt(隨機數),後臺服務器php : 截取salt後的數與數據庫的密碼進行比較;生成密碼:md5()
  • 用RSA進行加密傳輸
  • 使用密碼空間,進行加密傳輸
  • 有服務端頒發並驗證一個帶有時間戳的可信token

 

在固定字符串上截取隨機長度和打亂順序的字符串安全

function randomString(length) {
    var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split('');
   
    if (! length) {
        length = Math.floor(Math.random() * chars.length);
    }
   
    var str = '';
    for (var i = 0; i < length; i++) {
        str += chars[Math.floor(Math.random() * chars.length)];
    }
    return str;
}

 RSA加密服務器

  1. 後端先給前端發放一個公鑰(public-key)
  2. 前端使用公鑰對密碼(password)等敏感字段進行加密
  3. 前端使用post方式將使用公鑰加密後的密碼發送到後端
  4. 後端使用私鑰(private-key)進行解密,得到原密碼

 

MD5實現的前端加密dom

  • MD5定義

  MD5 is a secure hash algorithm. It takes a string as input, and produces a 128-bit number, the hash. The same string always produces the same hash, but given a hash, it is not generally possible to determine the original string. Secure hash algorithms are useful for protecting passwords and ensuring data integrity.post

相關文章
相關標籤/搜索