Advertisement
Guest User

Untitled

a guest
Mar 7th, 2011
565
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <cstdio>
  3. #include <string.h>
  4. #include <iostream>
  5. using namespace std;
  6.  
  7. int main(int argc, char **argv)
  8. {
  9.   // blowfish key
  10.   const char *key = "h&6^5fVghasV_Fte";
  11.   BF_KEY bfKey;
  12.   BF_set_key(&bfKey, strlen(key), (const unsigned char*)key);
  13.  
  14.   // encrypt
  15.   const unsigned char *inStr = (const unsigned char *)"hello world\0";
  16.   unsigned char *outStr = (unsigned char *)malloc(sizeof(unsigned char) * 100);
  17.   BF_ecb_encrypt(inStr, outStr, &bfKey, BF_ENCRYPT);
  18.  
  19.   // decrypt
  20.   unsigned char buf[100];
  21.   BF_ecb_encrypt((const unsigned char*)outStr, buf, &bfKey, BF_DECRYPT);
  22.   std::cout << "decrypted: " << buf << "\n";
  23.   free(outStr);
  24.  
  25.   return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement