From 69a41f3322b28bdf45fc179e3cf99c525c2a8ad9 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 25 Oct 2021 07:45:11 +0200 Subject: [PATCH] [DEV] uptate new lutin declaration model --- GLD_algue.json | 38 ++++++++++++++++++++++++++++++++++++++ algue/sha512.cpp | 26 ++++++++++++++++++++++++++ algue/sha512.hpp | 1 + lutin_algue.py | 46 ---------------------------------------------- 4 files changed, 65 insertions(+), 46 deletions(-) create mode 100644 GLD_algue.json delete mode 100644 lutin_algue.py diff --git a/GLD_algue.json b/GLD_algue.json new file mode 100644 index 0000000..69ca28b --- /dev/null +++ b/GLD_algue.json @@ -0,0 +1,38 @@ +{ + "type":"LIBRARY", + "group-id":"com.atria-soft", + "description":"Algorithm generic", + "license":"MPL-2", + "license-file":"file://LICENCE.txt", + "maintainer":"file://authors.txt", + "author":"file://authors.txt", + "version":"file://version.txt", + "code-quality":"MEDIUM", + + "source": [ + "algue/debug.cpp", + "algue/base64.cpp", + "algue/sha1.cpp", + "algue/sha512.cpp", + "algue/md5.cpp" + ], + "header": [ + "algue/base64.hpp", + "algue/sha1.hpp", + "algue/sha512.hpp", + "algue/md5.hpp" + ], + "path":[ + "." + ], + "compilation-version": { + "language": "c++", + "version": 2017 + }, + "dependency": [ + "elog", + "etk", + "crypto", + "ememory" + ] +} \ No newline at end of file diff --git a/algue/sha512.cpp b/algue/sha512.cpp index 7d286cf..76b2b79 100644 --- a/algue/sha512.cpp +++ b/algue/sha512.cpp @@ -264,3 +264,29 @@ etk::Vector algue::sha512::encodeFromFile(const etk::Uri& _uri) { return ctx.finalize(); } +etk::Vector algue::sha512::encodeFromFile(ememory::SharedPtr _file) { + algue::Sha512 ctx; + if (_file == null) { + ALGUE_ERROR("File Does not exist: "); + etk::Vector out; + out.resize(ALGUE_DIGEST_SIZE, 0); + } + if (_file->open(etk::io::OpenMode::Read) == false) { + ALGUE_ERROR("Can not open (r) the file: "); + etk::Vector out; + out.resize(ALGUE_DIGEST_SIZE, 0); + } + _file->seek(0, etk::io::SeekMode::Start); + + uint32_t bufferSize = 4096; + uint8_t buffer[bufferSize]; + while (bufferSize == 4096) { + bufferSize = _file->read(buffer, 1, bufferSize); + if (bufferSize != 0) { + ctx.update(buffer, bufferSize); + } + } + _file->close(); + return ctx.finalize(); +} + diff --git a/algue/sha512.hpp b/algue/sha512.hpp index 1a0ea31..ad3c950 100644 --- a/algue/sha512.hpp +++ b/algue/sha512.hpp @@ -41,6 +41,7 @@ namespace algue { return algue::sha512::encode(reinterpret_cast(&_data[0]), _data.size()); } etk::Vector encodeFromFile(const etk::Uri& _uri); + etk::Vector encodeFromFile(ememory::SharedPtr _file); } etk::String stringConvert(etk::Vector _data); } diff --git a/lutin_algue.py b/lutin_algue.py deleted file mode 100644 index b4ddf21..0000000 --- a/lutin_algue.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/python -import lutin.debug as debug -import lutin.tools as tools - - -def get_type(): - return "LIBRARY" - -def get_desc(): - return "Algorithm generic" - -def get_licence(): - return "MPL-2" - -def get_compagny_type(): - return "com" - -def get_compagny_name(): - return "atria-soft" - -def get_maintainer(): - return "authors.txt" - -def get_version(): - return "version.txt" - -def configure(target, my_module): - my_module.add_depend(['elog', 'etk', 'crypto']) - my_module.add_extra_flags() - my_module.add_src_file([ - 'algue/debug.cpp', - 'algue/base64.cpp', - 'algue/sha1.cpp', - 'algue/sha512.cpp', - 'algue/md5.cpp' - ]) - my_module.add_header_file([ - 'algue/base64.hpp', - 'algue/sha1.hpp', - 'algue/sha512.hpp', - 'algue/md5.hpp', - ]) - my_module.add_path(".") - return True - -