00001 #ifndef INCLUDE_COND_CIPHER_H 00002 #define INCLUDE_COND_CIPHER_H 00003 00004 #include <iostream> 00005 #include <string> 00006 00007 struct BLOWFISH_CTX; 00008 00009 namespace cond { 00010 00011 class Cipher { 00012 public: 00013 00014 explicit Cipher( const std::string& key ); 00015 00016 ~Cipher(); 00017 00018 size_t encrypt( const std::string& input, unsigned char*& output ); 00019 00020 std::string decrypt( const unsigned char* input, size_t inputSize ); 00021 00022 std::string b64encrypt( const std::string& input ); 00023 00024 std::string b64decrypt( const std::string& input ); 00025 00026 private: 00027 00028 size_t bf_process_alloc( const unsigned char* input, size_t input_size, unsigned char*& output, bool decrypt=false ); 00029 00030 private: 00031 00032 BLOWFISH_CTX* m_ctx; 00033 }; 00034 00035 } 00036 00037 #endif 00038