欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

C# Base 64 编码/解码实现代码

程序员文章站 2023-02-22 19:38:51
1、base64 to string string strpath = "ahr0cdovlziwmy44ms4yos40njo1ntu3l1 9iyw...

1、base64 to string

   string strpath = "ahr0cdovlziwmy44ms4yos40njo1ntu3l1
 9iywlkds9yaw5ncy9tawrplziwmda3mzgwlte2lm1pza==";     
   byte[] bpath = convert.frombase64string(strpath);
   strpath = system.text.asciiencoding.default.getstring(bpath);

2、string to base64

system.text.encoding encode = system.text.encoding.ascii ;
byte[] bytedata = encode.getbytes( "test");
string strpath = convert.tobase64string(bytedata,0,bytedata.length);