base64

i have a function written in java programming, i want to convert it into the php.

public static String convertHexString(String hex){ byte[] bytes = new byte[hex.length() / 2]; for (int i = 0; i < bytes.length; i++) { bytes[i] = (byte) Integer.parseInt(hex.substring(2 * i,2 * i + 2), 16); } sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder(); System.out.println(encoder.encode(bytes)); return encoder...

How can I create a string of random characters (as for a password...)?

I've written some code to generate a sequence of random characters, but it does not: byte[] sbytes = { 1, 0, 1, 0, 1 }; String sstring; System.Random r = new System.Random(); r.NextBytes(sbytes); sstring = Convert.ToBase64String(sbytes); sstring = Path.GetRandomFileName(); sstri...

Get pixel color of Base64 PNG using javascript?

I have a base64 encoded PNG. I need to get the color of a pixel using javascript. I assume I'll have to convert it back to a normal PNG. Can anyone point me in the right direction? ...

Issue sending a base64 encoded string via HTTP with .NET

Ok, so the problem is I'm trying to send a byte array via HTTP encoded as base64. While the string I receive on the other end is the same size as the original string, the strings themselves are not identical, hence I can't decode the string back to the original byte array. Also, I've done conversion to/from base64 on the client side bef...

Why do we use Base64?

Wikipedia says Base64 encoding schemes are commonly used when there is a need to encode binary data that needs be stored and transferred over media that are designed to deal with textual data. This is to ensure that the data remains intact without modification during transport. But is it not that data is always stored/transmitted i...

JQuery base64 function implementation

I can't figure out why is not working a jquery plugin (base64 encode decode) inside an event function. This way works: $(document).ready(function(){ data = $.base64Encode('something'); alert(data); }); But when trying to add in an event function, I get the $.base64Encode is not a function error $(document)....

Mime / Base 64 encoding

hi ! I need a way to encode a string to Mime/Base64 in Delphi 7 and PHP These two encoders must be compatible :) thanks in advance :) ...

base64 decryption

Hi ! I am currently trying to decode a base64 encrypted PHP file , but without any luck. Could someone be able to help? http://pastebin.com/QmCdtDne Thanks ...

different results for openssl base64 and PHP base64_encode

I am trying to base64 encode a string in PHP and openssl. openssl: echo -n "1234567890A" | openssl enc -base64 php: $hash = sha1("1234567890A", true); var_dump($hash); echo base64_encode($hash); the results differ: openssl: MTIzNDU2Nzg5MEE= PHP: /Q6nenquhGpX5h2WdiQZQF47Pe8= I guess this is just a simple setting I can use to a...

Serializing a Struct

UPDATE The problem is no longer in the struct itself, but in my GetSerializerFor(Type typeOfT) method shown below Original Question I have the following struct that serializes to <Base64String><string>valuehere</string></Base64String> I want it to serialize to simply <string>valuehere</string> But I can't get it to work, I have...

Convert Image JPG to GIF and print it into the tag IMG in BASE64

This is my actual code, I have troubles related with the right visualization of the gif image generated on the fly for my php script. If I access directly to the gif image generated by the script the browser show it good but if I try from my current script through tag img, the browser couldn't show it. Any suggest friends ? <?php $src ...

Howto Base64 decode (library) in J2ME?

There are lots of Base64 libraries for Java SE but I can't seem to find one for J2ME. Does any one have a algorithm or library in their coding toolkit? I receive following from a REST webservice (cut for clearity) : [137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,1,64,0,0,0,46] How do I decode the string above? Thanks! ...

Node.js base64 encode a downloaded image for use in data URI

Using Node v0.2.0 I am trying to fetch an image from a server, convert it into a base64 string and then embed it on the page in an image tag. I have the following code: var express = require('express'), request = require('request'), sys = require('sys'); var app = express.createServer( express.logger(), express.bodyDecoder() );...

Bad Base64 encoding using libssl

Assuming the following code, i have strange error in my base64 encodings. #include <openssl/bio.h> #include <openssl/buffer.h> #include <stdio.h> #include <string.h> char * base64(unsigned char * input, int length) { BIO *b64 = NULL; BIO * bmem = NULL; BUF_MEM *bptr = NULL; char * output = NULL; b64 = BIO_new((BIO...

Encoding an image file with base64

I want to encode an image into a string using the base64 module. I've ran into a problem though. How do I specify the image I want to be encoded? I tried using the directory to the image, but that simply leads to the directory being encoded. I want the actual image file to be encoded. EDIT I tired this snippet: with open("C:\Python...

How to convert base64 string to binary array using php.

Hi, I have base 64 encoded string that looks something like this. cuVrcYvlqYze3OZ8Y5tSqQY205mcquu0GsHkgXe4bPg= I have tried base64_decode and output is. råkq‹å©ŒÞÜæ|c›R©6Ó™œªë´Áäw¸lø I think I may be doing something wrong. I appreciate any help to convert base64 string to binary array. Thanks ...

HTML5 canvas image how can be saved in SVG or base 64 format?

can we export canvas image as svg or base 64 and then import it back again? ...

How does IXmlSerializable let me avoid base64's size inflation?

From MSDN: There are two reasons to implement this interface. The first is to control how your object is serialized or deserialized by the XmlSerializer. For example, you can chunk data into bytes instead of buffering large data sets, and also avoid the inflation that occurs when the data is encoded using Base64 encoding. How does ...

How to convert string to base64 ASCII Embedded in c

Possible Duplicate: How do I base64 encode (decode) in C? I am trying to convert an int into an ASCII byte array and then encode the byte array as a base64 string. I see a few posts on how to do this in C# and Java, but I want to do this in C. I'm doing this in windows, using MS Visual Studio. Is there a function provide...

PHP - add/remove carriage returns to a base 64 encoded string

Hi I have a verrrrrrrry long base64 encoded string which is displayed in a textarea. The problem is that this string doesn't have any spaces or carriage returns so it gets displayed on one line with a ugly horizontal scroll bar. Can I add somehow carriage returns manually after base64_encode() and before output to the textarea, then re...