Base64 Encode/Decode compatible with openssl EVP_Decode/Encode
From: Ramy076 (ramy076_at_yahoo.com)
Date: 04/01/04
- Next message: gurtd_dauberie_at_hta-bi.bfh.ch to send email write without _dauberie: "Re: Java and IP address on linux"
- Previous message: Herman Timmermans: "Re: html in textarea"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 1 Apr 2004 03:47:09 -0800
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,"1234567899adserffsgbhgrthfbsdferwsdfghjtyjf+dfgDGRdgHEsdfGRSGH+ASD/FG/sdfesfgW/SFVGHeERT4sEYJ5+sdfERSDFGesfsfJTdfTGJfsSfSHfEZpsdfa36fsJf3sdfaSDFSEFHYUKMF5dfftsadfsd+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/detail.php?type=snippet&id=100549
- both the results are the same.
java com.Ostermiller.util.Base64 -vd
1234567899adserffsgbhgrthfbsdferwsdfghjtyjf+dfgDGRdgHEsdfGRSGH+ASD/FG/sdfesfgW/SFVGHeERT4sEYJ5+sdfERSDFGesfsfJTdfTGJfsSfSHfEZpsdfa36fsJf3sdfaSDFSEFHYUKMF5dfftsadfsd+asffES=
- Next message: gurtd_dauberie_at_hta-bi.bfh.ch to send email write without _dauberie: "Re: Java and IP address on linux"
- Previous message: Herman Timmermans: "Re: html in textarea"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|