I tried to decrypt the encrypted texts, which is encrypted by C Language
library,
on commandline , but it didn't work well.
Please tell me how I can decrypt the encrypted texts, encrypted by C
Language library,
on commandline.
unsigned char outbuf[1024];
int outlen, tmplen;
unsigned char key[] = "0123456789012345";
unsigned char iv[] = "00000000";
char intext[] = "Some Crypto Text";
EVP_CIPHER_CTX ctx;
FILE *out;
char outfile[ 256] = ".\\outfile.txt";
EVP_CIPHER_CTX_init(&ctx);
//Blowfish CBCモードを採用.
EVP_EncryptInit_ex(&ctx, EVP_bf_cbc(), NULL, key, iv);
if( !EVP_EncryptUpdate( &ctx, outbuf, &outlen, ( unsigned char*)intext,
strlen
(intext)))
{
/* Error */
return 0;
}
if(!EVP_EncryptFinal_ex(&ctx, outbuf + outlen, &tmplen))
{
/* Error */
return 0;
}
outlen += tmplen;
EVP_CIPHER_CTX_cleanup(&ctx);
out = fopen(outfile, "wb");
fwrite(outbuf, 1, outlen, out);
fclose(out);
The encrypted texts is output as "outfile.txt".
Then, I tried to decrypt the encrypted texts as "decfile.txt" on commandline.
OpenSSL> enc -d -bf-cbc -k 0123456789012345 -iv 00000000 -in
outfile.txt -out
decfile.txt
But, the following massage is displayed, and it can't be decrypted.
bad magic number
error in enc
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List openssl-dev@openssl.org
Automated List Manager [EMAIL PROTECTED]