diff options
Diffstat (limited to 'nacl/crypto_stream/wrapper-stream.cpp')
-rw-r--r-- | nacl/crypto_stream/wrapper-stream.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/nacl/crypto_stream/wrapper-stream.cpp b/nacl/crypto_stream/wrapper-stream.cpp new file mode 100644 index 00000000..dd10c2f6 --- /dev/null +++ b/nacl/crypto_stream/wrapper-stream.cpp | |||
@@ -0,0 +1,12 @@ | |||
1 | #include <string> | ||
2 | using std::string; | ||
3 | #include "crypto_stream.h" | ||
4 | |||
5 | string crypto_stream(size_t clen,const string &n,const string &k) | ||
6 | { | ||
7 | if (n.size() != crypto_stream_NONCEBYTES) throw "incorrect nonce length"; | ||
8 | if (k.size() != crypto_stream_KEYBYTES) throw "incorrect key length"; | ||
9 | unsigned char c[clen]; | ||
10 | crypto_stream(c,clen,(const unsigned char *) n.c_str(),(const unsigned char *) k.c_str()); | ||
11 | return string((char *) c,clen); | ||
12 | } | ||