加密和解密任何字符串的方法 [英] the way to encrypt and decrypt the any string
本文介绍了加密和解密任何字符串的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您能否告诉我加密和解密任何字符串的方法
could u tell me the way to encrypt and decrypt the any string
推荐答案
请参见以下链接:
使用源代码进行简单的字符串加密和解密 [ ^ ]
加密和解密字符串 [
See the following links:
Simple String Encryption and Decryption with Source Code[^]
Encrypt and Decrypt a String[^]
For Decrypt
byte[] encData_byte = new byte[string.Length];
encData_byte = System.Text.Encoding.UTF8.GetBytes(Textbox3.Text);
string encodedData = Convert.ToBase64String(encData_byte);
result= encodedData;
用于加密:
for Encrypt:
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();
byte[] todecode_byte = Convert.FromBase64String(string);
int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
char[] decoded_char = new char[charCount];
utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
string result = new String(decoded_char);
这篇关于加密和解密任何字符串的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文