[DEV] add sha512
This commit is contained in:
parent
4df549c566
commit
ff1b9c081b
17
algue/sha512.cpp
Normal file
17
algue/sha512.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#include <etk/types.h>
|
||||
#include <algue/sha512.h>
|
||||
#include <openssl/sha.h>
|
||||
|
||||
std::vector<uint8_t> algue::sha512::encode(const uint8_t* _data, int32_t _len) {
|
||||
std::vector<uint8_t> out;
|
||||
out.resize(SHA512_DIGEST_LENGTH);
|
||||
SHA512(_data, _len, &out[0]);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
20
algue/sha512.h
Normal file
20
algue/sha512.h
Normal file
@ -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 <etk/types.h>
|
||||
|
||||
namespace algue {
|
||||
namespace sha512 {
|
||||
std::vector<uint8_t> encode(const uint8_t* _data, int32_t _len);
|
||||
inline std::vector<uint8_t> encode(const std::vector<uint8_t>& _data) {
|
||||
return algue::sha512::encode(&_data[0], _data.size());
|
||||
}
|
||||
inline std::vector<uint8_t> encode(const std::string& _data) {
|
||||
return algue::sha512::encode(reinterpret_cast<const uint8_t*>(&_data[0]), _data.size());
|
||||
}
|
||||
}
|
||||
}
|
@ -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__))
|
||||
|
Loading…
x
Reference in New Issue
Block a user