documentation for PICrypt

git-svn-id: svn://db.shs.com.ru/pip@102 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
2015-04-15 14:23:00 +00:00
parent 85d90729fa
commit 9435ef726b
4 changed files with 59 additions and 9 deletions

View File

@@ -21,6 +21,8 @@
#ifdef PIP_CRYPT
# include "sodium.h"
#endif
const char hash_def_key[] = "_picrypt_";
@@ -144,6 +146,17 @@ PIByteArray PICrypt::hash(const PIString & secret) {
}
PIByteArray PICrypt::generateKey() {
PIByteArray hash;
#ifdef PIP_CRYPT
sodium_init();
hash.resize(crypto_secretbox_KEYBYTES);
randombytes_buf(hash.data(), hash.size());
#endif
return hash;
}
int PICrypt::sizeKey() {
#ifdef PIP_CRYPT
return crypto_secretbox_KEYBYTES;