By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,883 Members | 1,437 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,883 IT Pros & Developers. It's quick & easy.

Base64 Encode/Decode compatible with openssl EVP_Decode/Encode

P: n/a
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_.7u...`.K.|dR..H? ..}..o
Output from Java: 128 bytes including a new line char.

Following is the code in both C and Java
C Code:

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

strcpy(my,"1234567899adserffsgbhgrthfbsdferwsdfghj tyjf+dfgDGRdgHEsdfGRSGH+ASD/FG/sdfesfgW/SFVGHeERT4sEYJ5+sdfERSDFGesfsfJTdfTGJfsSfSHfEZpsdf a36fsJf3sdfaSDFSEFHYUKMF5dfftsadfsd+asffES=");
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 i also tried the B64 class
- 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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.