Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <cstdio>
- #include <string.h>
- #include <iostream>
- using namespace std;
- int main(int argc, char **argv)
- {
- // blowfish key
- const char *key = "h&6^5fVghasV_Fte";
- BF_KEY bfKey;
- BF_set_key(&bfKey, strlen(key), (const unsigned char*)key);
- // encrypt
- const unsigned char *inStr = (const unsigned char *)"hello world\0";
- unsigned char *outStr = (unsigned char *)malloc(sizeof(unsigned char) * 100);
- BF_ecb_encrypt(inStr, outStr, &bfKey, BF_ENCRYPT);
- // decrypt
- unsigned char buf[100];
- BF_ecb_encrypt((const unsigned char*)outStr, buf, &bfKey, BF_DECRYPT);
- std::cout << "decrypted: " << buf << "\n";
- free(outStr);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement