1
0
mirror of https://github.com/biergaizi/codecrypt synced 2024-07-03 00:44:07 +00:00
codecrypt/src/sha_hash.h

82 lines
1.9 KiB
C
Raw Normal View History

2012-12-29 19:35:42 +00:00
/*
* This file is part of Codecrypt.
*
* Codecrypt is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Codecrypt is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Codecrypt. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _ccr_sha_hash_h_
#define _ccr_sha_hash_h_
2012-12-29 19:35:42 +00:00
#if HAVE_CRYPTOPP==1
2012-12-29 19:35:42 +00:00
#include "hash.h"
#include <crypto++/sha.h>
2012-12-29 19:35:42 +00:00
class sha256hash : public hash_func
{
public:
uint size() {
return CryptoPP::SHA256::DIGESTSIZE;
2012-12-29 19:35:42 +00:00
}
std::vector<byte> operator() (const std::vector<byte>&a) {
std::vector<byte> r;
r.resize (size() );
CryptoPP::SHA256().CalculateDigest (& (r[0]),
& (a[0]),
a.size() );
2012-12-29 19:35:42 +00:00
return r;
}
};
2013-05-01 13:49:40 +00:00
class sha384hash : public hash_func
{
public:
uint size() {
return CryptoPP::SHA384::DIGESTSIZE;
2013-05-01 13:49:40 +00:00
}
std::vector<byte> operator() (const std::vector<byte>&a) {
std::vector<byte> r;
r.resize (size() );
CryptoPP::SHA384().CalculateDigest (& (r[0]),
& (a[0]),
a.size() );
2013-05-01 13:49:40 +00:00
return r;
}
};
2012-12-29 19:35:42 +00:00
class sha512hash : public hash_func
{
public:
uint size() {
return CryptoPP::SHA512::DIGESTSIZE;
2012-12-29 19:35:42 +00:00
}
std::vector<byte> operator() (const std::vector<byte>&a) {
std::vector<byte> r;
r.resize (size() );
CryptoPP::SHA512().CalculateDigest (& (r[0]),
& (a[0]),
a.size() );
2012-12-29 19:35:42 +00:00
return r;
}
};
#endif //HAVE_CRYPTOPP==1
2012-12-29 19:35:42 +00:00
#endif