c#中 base64字符串与普通字符串互转

来源:互联网 发布:集团军总司令源码程序 编辑:程序博客网 时间:2024/05/17 04:58

c#中 base64字符串与普通字符串互转


转成 Base64 形式的 System.String:
    string a = "base64字符串与普通字符串互转";  
    byte[] b = System.Text.Encoding.Default.GetBytes(a);      
    //转成 Base64 形式的 System.String  
    a = Convert.ToBase64String(b);  
    Response.Write(a);  

 
转回到原来的 System.String:


    byte[] c = Convert.FromBase64String(a);  
    a = System.Text.Encoding.Default.GetString(c);  
    Response.Write(a);
 
0 0
原创粉丝点击