开发者

C# How to encrypt string in which result are letters or numbers only without any other character?

开发者 https://www.devze.com 2023-01-13 00:51 出处:网络
I use some code to encrypt & decrypt string开发者_如何学C in C# but i want a good one that can generate encrypted string that contain only letters or numbers not any other ( + , / , ...)

I use some code to encrypt & decrypt string开发者_如何学C in C# but i want a good one that can generate encrypted string that contain only letters or numbers not any other ( + , / , ...)

Is there good one for that ?


You could use any encryption algorithm, then encode the result. Once you have binary data, you can push it out to any textual format. The result of an encryption algorithm is going to be a series of bytes, anyhow, so any textual representation is simply an encoding.

Hexadecimal would be fairly large, depending on your encrypted data. Base64 would almost encode it the way you want, except for the / and + symbols. Base32 would probably be the way to go, because it is A-Z, 2-7 and = for padding.

If you want to custom tailor your own encoding scheme, that is also an option, and would be very easy to implement. For example, you could take Base32, and replace the padding with 8, then you'd have just A-Z, 2-8.

0

精彩评论

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