]> git.stg.codes - stg.git/blob - stglibs/crypto.lib/include/stg/bfstream.h
Added stream encryption/decryption.
[stg.git] / stglibs / crypto.lib / include / stg / bfstream.h
1 #ifndef __STG_STGLIBS_BF_STREAM_H__
2 #define __STG_STGLIBS_BF_STREAM_H__
3
4 #include <string>
5 #include <cstddef> // size_t
6
7 namespace STG
8 {
9
10 class ENCRYPT_STREAM
11 {
12     public:
13         typedef void (* CALLBACK)(const void * block, size_t size, void * data);
14
15         ENCRYPT_STREAM(const std::string & key, CALLBACK callback, void * data);
16         ~ENCRYPT_STREAM();
17         void Put(const void * data, size_t size, bool last = false);
18
19     private:
20         class IMPL;
21
22         IMPL * m_impl;
23 };
24
25 class DECRYPT_STREAM
26 {
27     public:
28         typedef void (* CALLBACK)(const void * block, size_t size, void * data);
29
30         DECRYPT_STREAM(const std::string & key, CALLBACK callback, void * data);
31         ~DECRYPT_STREAM();
32         void Put(const void * data, size_t size, bool last = false);
33
34     private:
35         class IMPL;
36
37         IMPL * m_impl;
38 };
39
40 } // namespace STG
41
42 #endif