chore: revert util/crypto
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
@@ -4,7 +4,8 @@ project('matar', 'cpp',
|
|||||||
default_options : ['warning_level=3',
|
default_options : ['warning_level=3',
|
||||||
'werror=true',
|
'werror=true',
|
||||||
'optimization=3',
|
'optimization=3',
|
||||||
'cpp_std=c++20'])
|
'cpp_std=c++20',
|
||||||
|
'default_library=static'])
|
||||||
|
|
||||||
compiler = meson.get_compiler('cpp')
|
compiler = meson.get_compiler('cpp')
|
||||||
|
|
||||||
|
@@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <bit>
|
#include <bit>
|
||||||
#include <iomanip>
|
#include <fmt/core.h>
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
// Why I wrote this myself? I do not know
|
// Why I wrote this myself? I do not know
|
||||||
@@ -15,8 +14,8 @@ using std::rotr;
|
|||||||
template<typename std::size_t N>
|
template<typename std::size_t N>
|
||||||
std::string
|
std::string
|
||||||
sha256(std::array<uint8_t, N>& data) {
|
sha256(std::array<uint8_t, N>& data) {
|
||||||
std::stringstream ss;
|
|
||||||
// Assuming 1 byte = 8 bits
|
// Assuming 1 byte = 8 bits
|
||||||
|
std::string string;
|
||||||
size_t k = 512 - (N * 8 + 65) % 512;
|
size_t k = 512 - (N * 8 + 65) % 512;
|
||||||
size_t L = N + (65 + k) / 8;
|
size_t L = N + (65 + k) / 8;
|
||||||
size_t i = 0, j = 0;
|
size_t i = 0, j = 0;
|
||||||
@@ -109,12 +108,12 @@ sha256(std::array<uint8_t, N>& data) {
|
|||||||
h[j] += h0[j];
|
h[j] += h0[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
ss << std::hex << std::setfill('0');
|
|
||||||
|
|
||||||
for (j = 0; j < 8; j++)
|
for (j = 0; j < 8; j++)
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
ss << std::setw(2) << ((h[j] >> (24 - i * 8)) & 0xFF);
|
fmt::format_to(std::back_inserter(string),
|
||||||
|
"{:02x}",
|
||||||
|
((h[j] >> (24 - i * 8)) & 0xFF));
|
||||||
|
|
||||||
return ss.str();
|
return string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user