473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Base64 Encode/Decode compatible with openssl EVP_Decode/Encode

I have a C App which uses openssl for Encoding and decoding which
needs to be ported to java.

The decoded text does not match between the C App and the java App.
The size of the output itself is wrong. I think i am doing something
basically wrong. pls help.

Output is not the same as seen here because of special characters
Output from C: is only 12 bytes long

ýmýýýýýý.ýýý~ý.ý.ýýýýuýýýý_ý.ýý7ýuý...`.K.|dR..ýH? ý.ý.}ý..oý
Output from Java: 128 bytes including a new line char.

+mýtýný+ýýOý~+?ý
fýý8uýý-ý_ý?f-7ýuý???`?K?|dR?ýýH?+?v?}d?ýo-ýQýxDSG-?'ýýuý?H1Fzý8|ýý}1ý~-ýHw-fý?}ýý~-_ýý_i
+HAGaBý?ý_~ý?uv?ýý?|D
Following is the code in both C and Java
C Code:

char* my = new char(172);
char base64[78];
int x;
int keyLength;
EVP_ENCODE_CTX ctx;

getbaseData()
{
memset(my,0,172);
strcpy(my,"1234567899adserffsgbhgrthfbsdferwsdfghj tyjf+dfgDGRdgHEsdfGRSGH+ASD/FG/sdfesfgW/SFVGHeERT4sEYJ5+sdfERSDFGesfsfJTdfTGJfsSfSHfEZpsdf a36fsJf3sdfaSDFSEFHYUKMF5dfftsadfsd+asffES=");
EVP_DecodeInit(&ctx);
EVP_DecodeUpdate(&ctx, (unsigned char *)base64, &x, (unsigned char *)
my, 172);
keyLength = x; //getting 48
EVP_DecodeFinal(&ctx, (unsigned char *)&base64[x], &x);
keyLength += x; //getting 12
}
Java Code used the Base64 code from
http://ostermiller.org/utils/Base64.html i also tried the B64 class
from http://sourceforge.net/snippet/detai...ppet&id=100549
- both the results are the same.

java com.Ostermiller.util.Base64 -vd
1234567899adserffsgbhgrthfbsdferwsdfghjtyjf+dfgDGR dgHEsdfGRSGH+ASD/FG/sdfesfgW/SFVGHeERT4sEYJ5+sdfERSDFGesfsfJTdfTGJfsSfSHfEZpsdf a36fsJf3sdfaSDFSEFHYUKMF5dfftsadfsd+asffES=
Jul 17 '05 #1
0 4197

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Schneider Alexander | last post by:
Hello, I would to encode and respectively to decode string's. Now ist my question: Is there a Funktion into J2SE 1.4 API? Thanks Alexander Schneider
1
by: Oliver Kurz | last post by:
Hello, I have a problem by converting a string to base64 and back again. I have a string with german special chars like äöüß. This string i convert with base64str=base64.encode('äöüß') into...
1
by: Damir Hakimov | last post by:
Hi *! I found a strange bug in base64.encode and decode, when I try to encode - decode a file 1728512 bytes lenth. Is somebody meet with this? I don't attach the file because it big, but can...
4
by: John | last post by:
Hi all, I've been going through google and yahoo looking for a certain base64 decoder in C without success. What I'm after is something that you can pass a base64 encoded string into and get back...
3
by: Guoqi Zheng | last post by:
Dear sir, I need to decode base64 encoded email. I used below function but it does not work correctly, especially when I need to decode some Characters like Chinese, Can some one point out...
5
by: Jay | last post by:
I have bean trying to get my head around reading .GIF files from base64 strings, Basically I need to specify a filename and convert it to base64 then I can copy/past the string to wear I want it....
13
by: aruna.eies.eng | last post by:
i am currently trying to convert data into binary data.for that i need to know how to achieve it in c language and what are the libraries that we can use. so if any one can send me a sample code or...
10
by: pycraze | last post by:
Hi , I am currently trying to implement base64 encoding and decoding scheme in C . Python has a module , base64 , that will do the encoding and decoding with ease . I am aware of OpenSSL having...
3
by: d-fan | last post by:
void decodebio( unsigned char *encbuf, unsigned char * decbuf, int destbuf ) { /* Read Base64 encoded data from standard input and write the decoded data to standard output: */ BIO...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.