Tag Archives: base64
Convert Base64 encoded bitmap to file in C#
The static FromBase64String method on the Convert class returns a byte[] that contains the decoded elements of the String. byte[] imageBytes = bmpAsString.Base64DecodeString(); using (FileStream fstrm = new FileStream(@"C:\recdcopy.bmp",FileMode.CreateNew, FileAccess.Write)) { using (BinaryWriter writer = new BinaryWriter(fstrm)) { writer.Write(imageBytes); } … Continue reading
Decoding a Base64-Encoded binary
Using the static method Convert.FromBase64String on the Convert class, an encoded String may be decoded to its equivalent byte[]. Example: using System; static class MyModClass { public static byte[] Base64DecodeString(this string inputStr) { byte[] decodedByteArray = Convert.FromBase64String(inputStr); return (decodedByteArray); } … Continue reading
Encode a bitmap file into a string using Base64 in C#
byte[] image = null; using (FileStream filestrm = new FileStream(@"C:\mypic.bmp",FileMode.Open, FileAccess.Read)) { using (BinaryReader reader = new BinaryReader(filestrm)) { img = new byte[reader.BaseStream.Length]; for (int i = 0; i < reader.BaseStream.Length; i++) { img[i] = reader.ReadByte( ); } } } … Continue reading
Encode binary data As Base64 in C#
Generally a byte[] representing some binary information, such as a bitmap is encoded into a string so that it can be sent over a binary-unfriendly transport, such as email, using Base64. The static method Convert.ToBase64String on the Convert class can … Continue reading
XML-RPC Base64-Encoded Binary Data Type
To transfer binary information via XML-RPC we need to encode the data in base64 (serialization) and use the base64 tags as xml tags. Example Declaration: <param> <value> <base64>UHSYDhD1423Cc0Ad3NVP4OidTd8E1kRY5Edh</base64> </value> </param> Since PHP does not have a binary data type, developers … Continue reading