简体   繁体   中英

Encrypt and Decrypt information in a cookie

I need to securely crypt and decrypt information about users ( name, surname and user_id ) in cookies.

What is the best way to do this ? What encryption and decryption function do I need ?

Thanks ^_^

It's generally a bad idea: an attacker can do chosen-text dictionary attacks if they can guess what you might be putting in the cookie, which is quite likely, and securing a universal key is harder than looking after a database containing confidential information, because there is not much in the way of an audit trail for these kind of client-side web-based attacks.

If the cost of a security breach is low, then maybe you want to do this anyway. Just use a symmetric-key encryption algorithm .

在这里看看: http : //www.example-code.com/python/encryption.asp我建议使用DES或Blowfish

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM