From 6e4d46f8cf911b82a10e8cd25b65fcc421bbc712 Mon Sep 17 00:00:00 2001 From: Aleksi Lindeman <0xdec05eba@gmail.com> Date: Sat, 14 Apr 2018 19:45:15 +0200 Subject: Store database storage to files, also loading --- src/PasswordHash.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/PasswordHash.cpp (limited to 'src/PasswordHash.cpp') diff --git a/src/PasswordHash.cpp b/src/PasswordHash.cpp new file mode 100644 index 0000000..f6d3713 --- /dev/null +++ b/src/PasswordHash.cpp @@ -0,0 +1,23 @@ +#include "../include/odhtdb/PasswordHash.hpp" +#include + +namespace odhtdb +{ + OwnedMemory hashPassword(const DataView &plainPassword, const DataView &salt) + { + OwnedMemory result; + + const uint32_t tCost = 2; + const uint32_t mCost = 1 << 16; + const uint32_t parallelism = 1; + const uint32_t HASHLEN = 32; + + result.data = new uint8_t[HASHLEN]; + result.size = HASHLEN; + + if(argon2i_hash_raw(tCost, mCost, parallelism, plainPassword.data, plainPassword.size, salt.data, salt.size, result.data, HASHLEN) != ARGON2_OK) + throw std::runtime_error("Failed to hash password"); + + return result; + } +} -- cgit v1.2.3