What encryption algorithm is best for encrypting cookies?

后端 未结 13 1109
感动是毒
感动是毒 2020-11-30 17:29

Since this question is rather popular, I thought it useful to give it an update.

Let me emphasise the correct answer as given by AviD to

13条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 17:42

    As pointed out a few times in previous comments, you must apply integrity protection to any ciphertext that you send out to the user and accept back. Otherwise the protected data can be modified, or the encryption key recovered.

    Especially the PHP world is full of bad examples that ignore this (see PHP cryptography - proceed with care) but this does apply to any language.

    One of few good examples I've seen is PHP-CryptLib which uses combined encryption-authentication mode to do the job. For Python pyOCB offers similar functionality.

提交回复
热议问题