NazaraEngine/src/Nazara/Core/Hash/SHA1.cpp

50 lines
866 B
C++

// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/Hash/SHA1.hpp>
#include <Nazara/Core/Hash/SHA/Internal.hpp>
#include <Nazara/Core/Debug.hpp>
namespace Nz
{
HashSHA1::HashSHA1()
{
m_state = new SHA_CTX;
}
HashSHA1::~HashSHA1()
{
delete m_state;
}
void HashSHA1::Append(const UInt8* data, unsigned int len)
{
SHA1_Update(m_state, data, len);
}
void HashSHA1::Begin()
{
SHA1_Init(m_state);
}
ByteArray HashSHA1::End()
{
UInt8 digest[SHA1_DIGEST_LENGTH];
SHA1_End(m_state, digest);
return ByteArray(digest, SHA1_DIGEST_LENGTH);
}
unsigned int HashSHA1::GetDigestLength() const
{
return SHA1_DIGEST_LENGTH;
}
const char* HashSHA1::GetHashName() const
{
return "SHA1";
}
}