Update hashing library (#384)
This commit is contained in:
committed by
Vincent Herbet
parent
e24b9548d4
commit
ea43a61094
14
third_party/hashing/hashers/sha1.h
vendored
14
third_party/hashing/hashers/sha1.h
vendored
@@ -1,6 +1,6 @@
|
||||
// //////////////////////////////////////////////////////////
|
||||
// sha1.h
|
||||
// Copyright (c) 2014 Stephan Brumme. All rights reserved.
|
||||
// Copyright (c) 2014,2015 Stephan Brumme. All rights reserved.
|
||||
// see http://create.stephan-brumme.com/disclaimer.html
|
||||
//
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
class SHA1 //: public Hash
|
||||
{
|
||||
public:
|
||||
/// split into 64 byte blocks (=> 512 bits), hash is 20 bytes long
|
||||
enum { BlockSize = 512 / 8, HashBytes = 20 };
|
||||
|
||||
/// same as reset()
|
||||
SHA1();
|
||||
|
||||
@@ -35,8 +38,10 @@ public:
|
||||
/// add arbitrary number of bytes
|
||||
void add(const void* data, size_t numBytes);
|
||||
|
||||
/// return latest hash as 16 hex characters
|
||||
/// return latest hash as 40 hex characters
|
||||
const char* getHash();
|
||||
/// return latest hash as bytes
|
||||
void getHash(unsigned char buffer[HashBytes]);
|
||||
|
||||
/// restart
|
||||
void reset();
|
||||
@@ -47,15 +52,14 @@ private:
|
||||
/// process everything left in the internal buffer
|
||||
void processBuffer();
|
||||
|
||||
/// split into 64 byte blocks (=> 512 bits)
|
||||
enum { BlockSize = 512 / 8, HashValues = 5 };
|
||||
|
||||
/// size of processed data in bytes
|
||||
uint64_t m_numBytes;
|
||||
/// valid bytes in m_buffer
|
||||
size_t m_bufferSize;
|
||||
/// bytes not processed yet
|
||||
uint8_t m_buffer[BlockSize];
|
||||
|
||||
enum { HashValues = HashBytes / 4 };
|
||||
/// hash, stored as integers
|
||||
uint32_t m_hash[HashValues];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user