Detect base64 encoding in PHP?

后端 未结 12 1908
鱼传尺愫
鱼传尺愫 2020-12-05 02:10

Is there some way to detect if a string has been base64_encoded() in PHP?

We\'re converting some storage from plain text to base64 and part of it lives in a cookie

12条回答
  •  天命终不由人
    2020-12-05 02:44

    base64_decode() will not return FALSE if the input is not valid base64 encoded data. Use imap_base64() instead, it returns FALSE if $text contains characters outside the Base64 alphabet imap_base64() Reference

提交回复
热议问题