简体   繁体   中英

How to encrypt / decrypt a number into a string without using Base64

I have a number (int, long, double types) and I want to encrypt that number into a string with "alphabet or number" or "both alphabet and number" (non special characters).

Because I want to encrypt the UserId in a Url. I have seen some posts on the internet, but they always return a Base64 string, however I don't want to show Base64 string in Url.

P/s: I want encrypt / decrypt, NOT encode / decode.

You need to find a text based cypher, but I haven't ever heard of anyone. The best way to solve your problem is to combine encryption and base64 encoding. You encrypt the userid with a cypher of your choice (for example AES) and then you base64 encode the encrypted byte array to get a string representation.

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