base64

base64 png in python on Windows

How do you encode a png image into base64 using python on Windows? iconfile = open("icon.png") icondata = iconfile.read() icondata = base64.b64encode(icondata) The above works fine in Linux and OSX, but on Windows it will encode the first few characters then cut short. Why is this? ...

PHP base64_decode C# equivalent

I'm trying to mimic a php script that do the following : replace a GET vaiable's every space with a + sign ($var = preg_replace("/\s/","+",$_GET['var']); ) decoding to base64 : base64_decode($var); 1st i added a method perform a base64 decoding : public string base64Decode(string data) { try { ...

What's the best candidate padding char for url-safe and filename-safe base64?

The padding char for the official base64 is '=', which might need to be percent-encoded when used in a URL. I'm trying to find the best padding char so that my encoded string can be both url safe (I'll be using the encoded string as parameter value, such as id=encodedString) AND filename safe (I'll be using the encoded string directly as...

Serialize .NET Array to XML as base 64?

I'm writing a custom .NET serializer in C# and want to read and write Array objects to XML using XmlReader and XmlWriter. I would like to base64-encode the Array. The arrays may be 1-, 2- or 3-dimensional and the elements are bool or numeric types. I'm completely stumped. XmlReader and XmlWriter have methods for reading/writing Byte[] ...

Saving a Base64 string to disk as a binary using Delphi 2007

I have a Base64 binary string that is part of an XML document that is sent to us by a 3rd party supplier, I would like to be able to save it back to its original file format (jpg). Using the accepted answer from this question "saving a base64 string to disk as a binary using php" I can save the string to a jpg with little effort, so I k...

XML for Web Service: inline attachment

I have to invoke a web service with a single parameter, a String in XML format. I'm building this via an XSLT transformation. So far so good. The problem is with this XSD fragment: <xs:complexType name="Document"> <xs:sequence> <xs:element name="title" type="xs:string" minOccurs="1"/> <xs:element name="content" typ...

Base64 String throwing invalid character error.

I keep getting a Base64 invalid character error even though I shouldn't. The program takes an XML file and exports it to a document. If the user wants, it will compress the file as well. The compression works fine and returns a Base64 String which is encoded into UTF-8 and written to a file. When its time to reload the document into th...

.NET: Why isn't base 64 in Encoding.GetEncodings()?

I have a function that can decode an array of bytes into a string of characters using a specified encoding. Example: Function Decode(ByVal bytes() As Byte, ByVal codePage As String) As String Dim enc As Text.Encoding = Text.Encoding.GetEncoding(codePage) Return enc.GetString(bytes) End Function If I want to include base64 in ...

Storing UUID as base64 String

I have been experimenting with using UUIDs as database keys. I want to take up the least amount of bytes as possible, while still keeping the UUID representation human readable. I think that I have gotten it down to 22 bytes using base64 and removing some trailing "==" that seem to be unnecessary to store for my purposes. Are there an...

C#/.NET: GETting a URL with an url-encoded slash

I want to send a HTTP GET to http://example.com/%2F. My first guess would be something like this: using (WebClient webClient = new WebClient()) { webClient.DownloadData("http://example.com/%2F"); } Unfortunately, I can see that what is actually sent on the wire is: GET // HTTP/1.1 Host: example.com Connection: Keep-Alive So http:...

Whats the problem with this encrypted QueryString- Invalid length for a Base-64 char array.

I am encrypting a text and sending it via QueryString. "8ZnSq13yv2yYVDsehDnNUNp/yIFqsAQh4XNPbV1eLMpk/dMWpc/YnMMEBy29MlgcYqpV2XPOf/Rpiz5S85VN/fkLbGTCkL/clBHh983Cp s=" The Decrypt Function is given Below public static string Decrypt(string stringToDecrypt)//Decrypt the content { try { byte[] key = Convert2ByteArray(DESKey); byte[...

CryptBinaryToString isn't supported on Windows 2000. Is there and alternative?

The Windows API function CryptBinaryToString isn't supported on Windows 2000. Is there and alternative? The main use that I need, is to encode/decode BASE64 ...

Fast open source checksum for small strings

I need a quick checksum (as fast as possilbe) for small strings (20-500 chars). I need the source code and that must be small! (about 100 LOC max) If it could generate strings in Base32/64. (or something similar) it would be perfect. Basically the checksums cannot use any "bad" chars.. you know.. the usual (){}[].,;:/+-\| etc Clarifi...

how to create random folder names 12 characters long in .NET

I would like to create random folder names on my website to store images and their thumbnails, but instead of using the full version of a generated guid, i was thinking about using just part of it, maybe just the first 8 characters and possibly base64 encode it. i am worried about possible collisions though. Can someone point me in the...

Alternatives to sending an image in base64 via document literal SOAP

I'm currently modifying a document literal SOAP service for a business app which transfers data about customers backwards and forwards. A new requirement to transfer scanned document images has just been identified. The problem I have is that the proprietary language I use does not support SOAP attachments. The images being transferred...

Why does UIWebView shrink images?

I'm using a UIWebView to display images in base64 (http://www.abluestar.com/utilities/encode_base64/index.php). The UIWebView is set to "Scales Page To Fit" and Mode is "Left". The image might be 400px wide but once rendered in the UiWebView, it takes up not even half of the screen. I need to do something like style="width:800px;..." ...

How to Get UIImage from a 'Base64String' format raw image data, on iPhone?

Hello, In my application, I receive the image data from the server in a XML file. This data is of an image( .jpeg or .png or .tiff etc) which the server, converts into 'Base64String' format bytes to send to my application through the XML file. At my application side, the application stores these bytes, in the form of 'NSData' into a dat...

How to base64 encode on the iPhone

I have found a few examples that looked promising, but could never get any of them to work on the phone. ...

How to base64-decode large files in PHP

Hi all, My PHP web application has an API that can recieve reasonably large files (up to 32 MB) which are base64 encoded. The goal is to write these files somewhere on my filesystem. Decoded of course. What would be the least resource intensive way of doing this? Edit: Recieving the files through an API means that I have a 32MB string ...

Decode base64 String Java 5

Is there a straight forward way to decode a base64 string using ONLY THE JAVA 1.5 LIBRARIES? I have to use Java 1.5 due to cross platform compatibility issues between Windows and Mac OS X (only Mac 10.5 supports Java 1.6, everything lower than 10.5 has Java 1.5 as default). The object "sun.misc.Base64Decoder" exists in Java 6, but not...