From ff1b9c081b9be1ed0765002e83752a9528037601 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sun, 31 Jul 2016 15:06:54 +0200 Subject: [PATCH] [DEV] add sha512 --- algue/sha512.cpp | 17 +++++++++++++++++ algue/sha512.h | 20 ++++++++++++++++++++ lutin_algue.py | 2 ++ 3 files changed, 39 insertions(+) create mode 100644 algue/sha512.cpp create mode 100644 algue/sha512.h diff --git a/algue/sha512.cpp b/algue/sha512.cpp new file mode 100644 index 0000000..bc4335c --- /dev/null +++ b/algue/sha512.cpp @@ -0,0 +1,17 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license APACHE v2.0 (see license file) + */ +#include +#include +#include + +std::vector algue::sha512::encode(const uint8_t* _data, int32_t _len) { + std::vector out; + out.resize(SHA512_DIGEST_LENGTH); + SHA512(_data, _len, &out[0]); + return out; +} + + diff --git a/algue/sha512.h b/algue/sha512.h new file mode 100644 index 0000000..1ea1b72 --- /dev/null +++ b/algue/sha512.h @@ -0,0 +1,20 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license APACHE v2.0 (see license file) + */ +#pragma once + +#include + +namespace algue { + namespace sha512 { + std::vector encode(const uint8_t* _data, int32_t _len); + inline std::vector encode(const std::vector& _data) { + return algue::sha512::encode(&_data[0], _data.size()); + } + inline std::vector encode(const std::string& _data) { + return algue::sha512::encode(reinterpret_cast(&_data[0]), _data.size()); + } + } +} diff --git a/lutin_algue.py b/lutin_algue.py index ffc6705..a594b3b 100644 --- a/lutin_algue.py +++ b/lutin_algue.py @@ -32,11 +32,13 @@ def create(target, module_name): 'algue/debug.cpp', 'algue/base64.cpp', 'algue/sha1.cpp', + 'algue/sha512.cpp', 'algue/md5.cpp' ]) my_module.add_header_file([ 'algue/base64.h', 'algue/sha1.h', + 'algue/sha512.h', 'algue/md5.h', ]) my_module.add_path(tools.get_current_path(__file__))