CSharp examples for System:String Base64
Encode the byte data to base 64 writing it to the given output stream.
using System.Text; using System.IO;/*from www . ja v a 2 s . c om*/ using System; public class Main{ /** * Encode the byte data to base 64 writing it to the given output stream. * * @return the number of bytes produced. */ public static int Encode( byte[] data, int off, int length, Stream outStream) { string s = Convert.ToBase64String(data, off, length); byte[] encoded = Strings.ToAsciiByteArray(s); outStream.Write(encoded, 0, encoded.Length); return encoded.Length; } /** * Encode the byte data to base 64 writing it to the given output stream. * * @return the number of bytes produced. */ public static int Encode(byte[] data, Stream outStream) { string s = Convert.ToBase64String(data, 0, data.Length); byte[] encoded = Strings.ToAsciiByteArray(s); outStream.Write(encoded, 0, encoded.Length); return encoded.Length; } /** * encode the input data producing a base 64 encoded byte array. * * @return a byte array containing the base 64 encoded data. */ public static byte[] Encode(byte[] data) { string s = Convert.ToBase64String(data, 0, data.Length); return Strings.ToAsciiByteArray(s); } }