Compare commits

...

3 Commits
main ... dev

5 changed files with 68 additions and 47 deletions

37
GLD_algue.json Normal file
View File

@ -0,0 +1,37 @@
{
"type":"LIBRARY",
"group-id":"com.atria-soft",
"description":"Algorithm generic",
"license":"MPL-2",
"license-file":"file://LICENSE",
"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": {
"c++": 2017
},
"dependency": [
"elog",
"etk",
"crypto",
"ememory"
]
}

View File

@ -46,6 +46,7 @@
#include <algue/debug.hpp>
#include <etk/path/Path.hpp>
#include <etk/uri/provider/provider.hpp>
#include <etk/uri/uri.hpp>
static const uint32_t ALGUE_SHA384_512_BLOCK_SIZE = (1024/8);
static const uint32_t ALGUE_DIGEST_SIZE = ( 512 / 8);
@ -264,3 +265,29 @@ etk::Vector<uint8_t> algue::sha512::encodeFromFile(const etk::Uri& _uri) {
return ctx.finalize();
}
etk::Vector<uint8_t> algue::sha512::encodeFromFile(ememory::SharedPtr<etk::io::Interface> _file) {
algue::Sha512 ctx;
if (_file == null) {
ALGUE_ERROR("File Does not exist: ");
etk::Vector<uint8_t> 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<uint8_t> 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();
}

View File

@ -8,6 +8,8 @@
#include <etk/types.hpp>
#include <etk/Vector.hpp>
#include <etk/String.hpp>
#include <etk/io/Interface.hpp>
#include <ememory/SharedPtr.hpp>
#include <etk/uri/Uri.hpp>
namespace algue {
@ -41,6 +43,7 @@ namespace algue {
return algue::sha512::encode(reinterpret_cast<const uint8_t*>(&_data[0]), _data.size());
}
etk::Vector<uint8_t> encodeFromFile(const etk::Uri& _uri);
etk::Vector<uint8_t> encodeFromFile(ememory::SharedPtr<etk::io::Interface> _file);
}
etk::String stringConvert(etk::Vector<uint8_t> _data);
}

View File

@ -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

View File

@ -1 +1 @@
0.4.0
0.4.0-dev