47 lines
865 B
C++
47 lines
865 B
C++
/*
|
|
Copyright (c) 2014 IOnU Security Inc. All rights reserved
|
|
Created March 2014 by Kendrick Webster
|
|
|
|
Hash.cpp - implementation for Hash.hpp
|
|
*/
|
|
#include <string.h>
|
|
#include "Hash.hpp"
|
|
|
|
std::string ionu::hash::CHash::GetString(size_t n) const
|
|
{
|
|
sc_hash_state_t h = m_h;
|
|
std::string r;
|
|
while (n--)
|
|
{
|
|
r += b64char(sc_hash(&h, 0));
|
|
}
|
|
return r;
|
|
}
|
|
|
|
bool ionu::hash::CHash::IsString(const std::string& s) const
|
|
{
|
|
if (0 == s.length())
|
|
{
|
|
return false;
|
|
}
|
|
sc_hash_state_t h = m_h;
|
|
for (size_t n = 0; n < s.length(); n++)
|
|
{
|
|
if (b64char(sc_hash(&h, 0)) != s[n])
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
std::string ionu::hash::CHash::GetStringAndMix(size_t n)
|
|
{
|
|
std::string r;
|
|
while (n--)
|
|
{
|
|
r += b64char(sc_hash(&m_h, 0));
|
|
}
|
|
return r;
|
|
}
|