28 #define CIPHER_DEFAULT_CIPHER "aes-256-cbc"
29 #define CIPHER_DEFAULT_DIGEST "sha1"
30 #define CIPHER_DEFAULT_COUNT 1
82 typedef std::pair<uchar*,uint>
kv1_t;
97 Cipher(
const std::string& cipher,
98 const std::string& digest,
114 std::string
encrypt(
const std::string& plaintext,
115 const std::string& pass=
"",
116 const std::string& salt=
"");
158 const std::string& ofn,
159 const std::string& pass=
"",
160 const std::string& salt=
"");
169 std::string
decrypt(
const std::string& ciphertext,
170 const std::string& pass=
"",
171 const std::string& salt=
"");
211 const std::string& ofn,
212 const std::string& pass=
"",
213 const std::string& salt=
"");
222 uint ciphertext_len)
const;
245 uint ciphertext_len)
const;
253 std::string
file_read(
const std::string& fn)
const;
262 const std::string& data,
263 bool nl=
false)
const;
281 void set_salt(
const std::string& salt);
286 void init(
const std::string& pass);
std::string decrypt(const std::string &ciphertext, const std::string &pass="", const std::string &salt="")
Decrypt a buffer using AES 256 CBC (SHA1).
The cipher object encrypts plaintext data or decrypts ciphertext data.
std::pair< uchar *, uint > kv1_t
void encrypt_file(const std::string &ifn, const std::string &ofn, const std::string &pass="", const std::string &salt="")
Encrypt a file.
void file_write(const std::string &fn, const std::string &data, bool nl=false) const
Write ASCII data to a file.
std::string encrypt(const std::string &plaintext, const std::string &pass="", const std::string &salt="")
Encrypt buffer using AES 256 CBC (SHA1).
std::string decode_cipher(uchar *ciphertext, uint ciphertext_len) const
Cipher decode.
std::string file_read(const std::string &fn) const
Read a file into a buffer.
void set_salt(const std::string &salt)
Convert string salt to internal format.
void init(const std::string &pass)
Initialize the cipher: set the key and IV values.
kv1_t encode_cipher(const std::string &plaintext) const
Cipher encode.
std::string encode_base64(uchar *ciphertext, uint ciphertext_len) const
Base64 encode.
void debug(bool b=true)
Set the internal debug flag.
kv1_t decode_base64(const std::string &mimetext) const
Base64 decode.
void decrypt_file(const std::string &ifn, const std::string &ofn, const std::string &pass="", const std::string &salt="")
Decrypt a file.
bool debug() const
Is debug mode set?