Hi there!
I am writing a DLL which should get some data, encrypt them and then send them via query string to remote www server with php installed.
PHP has a library called mcrypt which supports a lot of encryption algorithms, but I think that BF and AES are the safest.
I have some big problems with encryption. This should be done in CBC mode. I do not have enough skills and knowledge to complete this task. That's why I am looking for a library which can do this. Raw implementation is too difficult for me.
But on the other hand, all libraries are very big (about 1Mb i.e. Libmcrypt or Crypto++).
Do you know any other libraries with only one or two algorithms implemented with CBC mode so the size wouldn't be so huge?
Or maybe you know any tutorials how to do this?
The most important thing is the size... which should be lower than 100k
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have already visited this page, but I still do not know how to encrypt a string in CBC mode.
The only source code that could be useful for me from http://www.schneier.com/blowfish-download.html is the reference code from SSleay 0.6.6 but I can't find blowfish.dll from this library.
Any other ideas or suggestions?
Please help...:)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Unpack the archive locally (I used 7-zip, which made a pigs ear of the symbolic links, but that won't matter)
In the unpacked archive, navigate to the crypto\bf directory. From, here, copy the files:
blowfish.h
bf_locl.h
bf_pi.h
bf_enc.c
bf_skey.c
to your project directory, and then add them all to the project in Dev-C++ (actually, you only really need to add the .C files, but hey...)
If you are programming in C++, you'll need to go to the project options, and make sure that the bf_enc.c and bf_skey.c are NOT set to compile as C++ (on the "Files" tab, select each file and untick the box)
Hey presto, you can now use the BF_cbc_encrypt function. You won't get a DLL doing it this way - the functions will be statically linked into your EXE.
Below is a sample program which I wrote which when added to a project as above compiles fine on my XP box with Dev-C++ 4.9.9.2:
Hope this helps,
Ian (cookies back again...)
--- snip ---
include <cstdlib>
include <iostream>
include "blowfish.h"
const long KEY_LENGTH = 16;
const long KEY_SEED = 0x1234;
//Displaytheunencryptedstringfor(inti=0;i<bf_len;++i)std::cout<<bf_in[i];std::cout<<std::endl;//Createarandomkey.Iwouldn't recommend the following in a// live environment......std::srand(KEY_SEED);for (int i = 0; i < KEY_LENGTH; ++i) ucharkey[i] = std::rand();// Create a random initial vector. I wouldn'trecommendthiseitherfor(inti=0;i<8;++i)ivec_start[i]=std::rand();std::memcpy(ivec_in,ivec_start,8);//ConvertourkeystringtoaBF-stylekeyBF_set_key(&key_in,KEY_LENGTH,ucharkey);//EncryptourteststringBF_cbc_encrypt(bf_in,bf_enc,bf_len,&key_in,ivec_in,BF_ENCRYPT);//Displaytheencrytedstringfor(inti=0;i<bf_len;++i)std::cout<<bf_enc[i];std::cout<<std::endl;//resettheinitialvectorstd::memcpy(ivec_in,ivec_start,8);//DecrypttheteststringBF_cbc_encrypt(bf_enc,bf_dec,bf_len,&key_in,ivec_in,BF_DECRYPT);//Displaythedecryptedstringfor(inti=0;i<bf_len;++i)std::cout<<bf_dec[i];std::cout<<std::endl;system("PAUSE");return0;
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi there!
I am writing a DLL which should get some data, encrypt them and then send them via query string to remote www server with php installed.
PHP has a library called mcrypt which supports a lot of encryption algorithms, but I think that BF and AES are the safest.
I have some big problems with encryption. This should be done in CBC mode. I do not have enough skills and knowledge to complete this task. That's why I am looking for a library which can do this. Raw implementation is too difficult for me.
But on the other hand, all libraries are very big (about 1Mb i.e. Libmcrypt or Crypto++).
Do you know any other libraries with only one or two algorithms implemented with CBC mode so the size wouldn't be so huge?
Or maybe you know any tutorials how to do this?
The most important thing is the size... which should be lower than 100k
Thanks
s
Download some code from here:
http://www.schneier.com/blowfish-download.html
Cheers,
Ian (cookies gone again...)
I have already visited this page, but I still do not know how to encrypt a string in CBC mode.
The only source code that could be useful for me from http://www.schneier.com/blowfish-download.html is the reference code from SSleay 0.6.6 but I can't find blowfish.dll from this library.
Any other ideas or suggestions?
Please help...:)
Go to ftp://ftp.psy.uq.oz.au/pub/Crypto/SSL/
Download the SSLeay-0.9.0b.tar.gz archive.
Unpack the archive locally (I used 7-zip, which made a pigs ear of the symbolic links, but that won't matter)
In the unpacked archive, navigate to the crypto\bf directory. From, here, copy the files:
blowfish.h
bf_locl.h
bf_pi.h
bf_enc.c
bf_skey.c
to your project directory, and then add them all to the project in Dev-C++ (actually, you only really need to add the .C files, but hey...)
If you are programming in C++, you'll need to go to the project options, and make sure that the bf_enc.c and bf_skey.c are NOT set to compile as C++ (on the "Files" tab, select each file and untick the box)
Hey presto, you can now use the BF_cbc_encrypt function. You won't get a DLL doing it this way - the functions will be statically linked into your EXE.
Below is a sample program which I wrote which when added to a project as above compiles fine on my XP box with Dev-C++ 4.9.9.2:
Hope this helps,
Ian (cookies back again...)
--- snip ---
include <cstdlib>
include <iostream>
include "blowfish.h"
const long KEY_LENGTH = 16;
const long KEY_SEED = 0x1234;
const long bf_len = 32;
int main()
{
unsigned char bf_in[bf_len+1] = "1 2 3 4 5 6 7 8 9 10 11 12 13 14";
unsigned char bf_enc[bf_len];
unsigned char bf_dec[bf_len];
unsigned char ucharkey[KEY_LENGTH];
BF_KEY key_in;
unsigned char ivec_start[8];
unsigned char ivec_in[8];
}
Thank you very much!
It works :)