documentation for PICrypt
git-svn-id: svn://db.shs.com.ru/pip@102 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user