Java – how to encode a string to replace all special characters

I have a string containing special characters But I have to convert a string to a string without any special characters, so I use Base64, but in Base64 we use the equals sign (=), which is a special character But I want to convert a string to a string with only alphanumeric characters In addition, I can't delete special characters. I just need to replace all special characters to maintain the uniqueness between two different strings How do I achieve this and what kind of coding will help me achieve this goal?

Solution

The simplest choice is to use UTF-8 to encode the text into binary, and then convert the binary file into text into hexadecimal (two characters per byte) It won't be very effective, but it's just alphanumeric

You can use base32 to improve efficiency, but this may significantly increase the workload unless you can find a library to support it (libraries that perform hexadecimal encoding are very common.)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>