Many methods now using vectors of blocks instead of flexblocks
This commit is contained in:
@@ -26,12 +26,31 @@ namespace Leonetienne::GCrypt {
|
||||
|
||||
~Basic_Block();
|
||||
|
||||
//! Will construct this block from a string like "011101..". Length MUST be 512.
|
||||
void FromString(const std::string& str);
|
||||
//! Will construct this block from a string like "011101..".
|
||||
void FromBinaryString(const std::string& str);
|
||||
|
||||
//! Will construct this block from a hexstring
|
||||
void FromHexString(const std::string& str);
|
||||
|
||||
//! Will construct this block from a bytestring (any characters)
|
||||
void FromByteString(const std::string& str);
|
||||
|
||||
//! Will construct this block from a textstring (any length)
|
||||
void FromTextString(const std::string& str);
|
||||
|
||||
//! Will create a bitset-compatible string ("0101110..") representation
|
||||
//! of this block. Length will always be 512.
|
||||
std::string ToString() const;
|
||||
std::string ToBinaryString() const;
|
||||
|
||||
//! Will create a hexstring representation of this block.
|
||||
std::string ToHexString() const;
|
||||
|
||||
//! Will create a bytestring representation of this block.
|
||||
std::string ToByteString() const;
|
||||
|
||||
//! Will create a textstring representation of this block.
|
||||
//! The difference to a bytestring is that it gets trimmed after a nullterminator.
|
||||
std::string ToTextString() const;
|
||||
|
||||
//! Will matrix-multiply two blocks together.
|
||||
//! Since the matrices values are pretty much sudo-random,
|
||||
|
@@ -4,6 +4,7 @@
|
||||
#include "GCrypt/Flexblock.h"
|
||||
#include "GCrypt/Block.h"
|
||||
#include "GCrypt/GCipher.h"
|
||||
#include <vector>
|
||||
|
||||
namespace Leonetienne::GCrypt {
|
||||
/** This class implements a hash function, based on the GCrypt cipher
|
||||
@@ -21,8 +22,14 @@ namespace Leonetienne::GCrypt {
|
||||
//! Will return the current hashsum
|
||||
const Block& GetHashsum() const;
|
||||
|
||||
//! Will calculate a hashsum for `data`.
|
||||
static Block CalculateHashsum(const Flexblock& data);
|
||||
//! Will calculate a hashsum for `blocks`.
|
||||
//! Whilst n_bytes is optional, it is HIGHLY recommended to supply.
|
||||
//! Without specifying the size of the input (doesn't always have to be 512*n bits)
|
||||
//! b'293eff' would hash to the exact same values as b'293eff0000'
|
||||
static Block CalculateHashsum(const std::vector<Block>& blocks, std::size_t n_bytes = std::string::npos);
|
||||
|
||||
//! Will calculate a hashsum for a string
|
||||
static Block HashString(const std::string& str);
|
||||
|
||||
void operator=(const GHash& other);
|
||||
|
||||
|
@@ -30,7 +30,7 @@ namespace Leonetienne::GCrypt {
|
||||
Flexblock StringToBits(const std::string& s);
|
||||
|
||||
//! Will convert a string to a vector of blocks
|
||||
std::vector<Block> StringToBitblocks(const std::string& s);
|
||||
std::vector<Block> StringToBitblocks(const std::string& str);
|
||||
|
||||
//! Will convert a fixed-size data block to a bytestring
|
||||
std::string BitblockToBytes(const Block& block);
|
||||
@@ -71,6 +71,9 @@ namespace Leonetienne::GCrypt {
|
||||
//! Will save bits to a binary file
|
||||
void WriteBitsToFile(const std::string& filepath, const Flexblock& bits);
|
||||
|
||||
//! Will read a file directly to data blocks, and yield the amount of bytes read
|
||||
std::vector<Block> ReadFileToBlocks(const std::string& filepath, std::size_t& bytes_read);
|
||||
|
||||
//! Will read a file directly to data blocks
|
||||
std::vector<Block> ReadFileToBlocks(const std::string& filepath);
|
||||
|
||||
|
Reference in New Issue
Block a user