mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-20 19:57:53 -05:00
SoundBankWriter code
This commit is contained in:
@ -1,10 +1,16 @@
|
||||
#include "Crypto.h"
|
||||
|
||||
#include "Impl/AlgorithmMD5.h"
|
||||
#include "Impl/AlgorithmRSA.h"
|
||||
#include "Impl/AlgorithmSHA1.h"
|
||||
#include "Impl/AlgorithmSHA256.h"
|
||||
#include "Impl/AlgorithmSalsa20.h"
|
||||
|
||||
std::unique_ptr<IHashFunction> Crypto::CreateMD5()
|
||||
{
|
||||
return std::make_unique<AlgorithmMD5>();
|
||||
}
|
||||
|
||||
std::unique_ptr<IHashFunction> Crypto::CreateSHA1()
|
||||
{
|
||||
return std::make_unique<AlgorithmSHA1>();
|
||||
|
@ -16,6 +16,8 @@ public:
|
||||
RSA_PADDING_PSS,
|
||||
};
|
||||
|
||||
static std::unique_ptr<IHashFunction> CreateMD5();
|
||||
|
||||
static std::unique_ptr<IHashFunction> CreateSHA1();
|
||||
static std::unique_ptr<IHashFunction> CreateSHA256();
|
||||
|
||||
|
64
src/Crypto/Impl/AlgorithmMD5.cpp
Normal file
64
src/Crypto/Impl/AlgorithmMD5.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
#include "AlgorithmSHA1.h"
|
||||
|
||||
#include "CryptoLibrary.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class AlgorithmSHA1::AlgorithmSHA1Impl
|
||||
{
|
||||
hash_state m_state{};
|
||||
|
||||
public:
|
||||
AlgorithmSHA1Impl()
|
||||
{
|
||||
CryptoLibrary::Init();
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
void Init()
|
||||
{
|
||||
sha1_init(&m_state);
|
||||
}
|
||||
|
||||
void Process(const void* input, const size_t inputSize)
|
||||
{
|
||||
sha1_process(&m_state, static_cast<const uint8_t*>(input), inputSize);
|
||||
}
|
||||
|
||||
void Finish(void* hashBuffer)
|
||||
{
|
||||
sha1_done(&m_state, static_cast<uint8_t*>(hashBuffer));
|
||||
}
|
||||
};
|
||||
|
||||
AlgorithmSHA1::AlgorithmSHA1()
|
||||
{
|
||||
m_impl = new AlgorithmSHA1Impl();
|
||||
}
|
||||
|
||||
AlgorithmSHA1::~AlgorithmSHA1()
|
||||
{
|
||||
delete m_impl;
|
||||
m_impl = nullptr;
|
||||
}
|
||||
|
||||
size_t AlgorithmSHA1::GetHashSize()
|
||||
{
|
||||
return HASH_SIZE;
|
||||
}
|
||||
|
||||
void AlgorithmSHA1::Init()
|
||||
{
|
||||
m_impl->Init();
|
||||
}
|
||||
|
||||
void AlgorithmSHA1::Process(const void* input, const size_t inputSize)
|
||||
{
|
||||
m_impl->Process(input, inputSize);
|
||||
}
|
||||
|
||||
void AlgorithmSHA1::Finish(void* hashBuffer)
|
||||
{
|
||||
m_impl->Finish(hashBuffer);
|
||||
}
|
20
src/Crypto/Impl/AlgorithmMD5.h
Normal file
20
src/Crypto/Impl/AlgorithmMD5.h
Normal file
@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include "IHashFunction.h"
|
||||
|
||||
class AlgorithmSHA1 : public IHashFunction
|
||||
{
|
||||
class AlgorithmSHA1Impl;
|
||||
AlgorithmSHA1Impl* m_impl;
|
||||
|
||||
public:
|
||||
static const int HASH_SIZE = 20;
|
||||
|
||||
AlgorithmSHA1();
|
||||
~AlgorithmSHA1() override;
|
||||
|
||||
size_t GetHashSize() override;
|
||||
|
||||
void Init() override;
|
||||
void Process(const void* input, size_t inputSize) override;
|
||||
void Finish(void* hashBuffer) override;
|
||||
};
|
Reference in New Issue
Block a user