加密敏感数据

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了加密敏感数据相关的知识,希望对你有一定的参考价值。

  1. //The concept is very similar to hashing the value, but now instead we will use a symmetric key to encrypt and decrypt the data.
  2.  
  3. $key = “This encrypting key should be long and complex.”;
  4. $encrypted_data = mcrypt_ecb (MCRYPT_3DES, $key, “12345”, MCRYPT_ENCRYPT); //encrypt using triple DES
  5. $id = urlencode(base64_encode($encrypted_data));
  6.  
  7. //The id will be base64 encoded and then urlencoded into Doj2VqhSe4k%3D so we will have the url as
  8.  
  9. //http://www.example.com/view_profile?id=Doj2VqhSe4k%3D
  10.  
  11. //(For perl programmer, you can use Digest::MD5 and Crypt::CBC to archive the same output)
  12.  
  13. //To decrypt the information we received we will do the following:
  14.  
  15. $id = $_REQUEST["id"]);
  16. $url_id = base64_decode(urldecode($id));
  17.  
  18. $decrypted_data = mcrypt_decrypt(MCRYPT_BLOWFISH,$key,$url_id, MCRYPT_MODE_CBC, $iv);
  19.  
  20. //The idea here is to url decode the input id value and follow by base64_decode it and then use back the same algorithm to get the actual data, which is 12345 in this case.
  21.  
  22. //This same idea can be used on session id to make sure the session id is not tampered with. One caveat to take note is encrypting and decrypting all data send and receive will possibly consume lot of cpu power, so make sure your system is properly size up.

以上是关于加密敏感数据的主要内容,如果未能解决你的问题,请参考以下文章

敏感数据加密

敏感数据加密保护和数据库访问方式的测试内容

加密敏感数据

数据库敏感数据加密技术

Jeecg-Boot前后端分离,针对敏感数据,加密传递方案

SpringBoot配置文件敏感信息加密