开发者

php base64_encode without the = sign

I'm using the开发者_StackOverflow社区 base64_encode function to hash strings. The strings must be a-zA-Z0-9 and sometimes base64_encode outputs the = sign at the end (sometimes twice).

What is the most efficient way to alter the base64_encode function (override?) to omit the = signs?


The possible =s at the end are required if you want to decode the value later. Also, the character set a-zA-Z0-9 has only 62 values and thus a base-64 encoded value can never fit inside it.

Update: If you need to hash strings, why not use a hash function? md5 should be a good go-to solution unless the application is security-sensitive, in which case a stronger hash (sha1 or better) should be used.


As Jon said you need the = to decode it later but from what you say you don't need to do that, in which case your better off using md5 instead, this will give you a 32 character A-F/0-9 string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜