Base64

Base64编码通常用于编码二进制数据,从而使二进制数据能存储在Xml或其他的文本格式中。(最常见于Email中)

例子:
CRc6tbZ+170rwAQ5bPNYXvc8M7cx+xeJiyrFBpda

C#中在Byte数组和Base64字符串之间转换很简单:

  1.            byte[] DataToEncode = new byte[30]; 
  2.  
  3.             // Fill the byte array with random data 
  4.             RandomNumberGenerator Generator = RandomNumberGenerator.Create(); 
  5.             Generator.GetNonZeroBytes(DataToEncode); 
  6.  
  7.             // Convert the byte array to a base-64 string 
  8.             string Base64String = Convert.ToBase64String(DataToEncode); 
  9.             Console.WriteLine("{0}",Base64String); 
  10.  
  11.             // Convert the base-64 string back to a byte array 
  12.             byte[] DecodedData = Convert.FromBase64String(Base64String); 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值