sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
SHA1 Class Reference

compute SHA1 hash More...

#include <sha1.h>

Public Types

enum  { BlockSize = 512 / 8 , HashBytes = 20 }
 split into 64 byte blocks (=> 512 bits), hash is 20 bytes long More...

Public Member Functions

 SHA1 ()
 same as reset()
std::string operator() (const void *data, size_t numBytes)
 compute SHA1 of a memory block
std::string operator() (const std::string &text)
 compute SHA1 of a string, excluding final zero
void add (const void *data, size_t numBytes)
 add arbitrary number of bytes
std::string getHash ()
 return latest hash as 40 hex characters
void getHash (unsigned char buffer[HashBytes])
 return latest hash as bytes
void reset ()
 restart

Detailed Description

compute SHA1 hash

Usage: SHA1 sha1; std::string myHash = sha1("Hello World"); // std::string std::string myHash2 = sha1("How are you", 11); // arbitrary data, 11 bytes

or in a streaming fashion:

SHA1 sha1;
while (more data available)
  sha1.add(pointer to fresh data, number of new bytes);
std::string myHash3 = sha1.getHash();

Definition at line 41 of file sha1.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

split into 64 byte blocks (=> 512 bits), hash is 20 bytes long

Definition at line 45 of file sha1.h.

Constructor & Destructor Documentation

◆ SHA1()

SHA1::SHA1 ( )

same as reset()

Definition at line 18 of file sha1.cpp.

Member Function Documentation

◆ add()

void SHA1::add ( const void * data,
size_t numBytes )

add arbitrary number of bytes

Definition at line 158 of file sha1.cpp.

◆ getHash()

std::string SHA1::getHash ( )

return latest hash as 40 hex characters

Definition at line 268 of file sha1.cpp.

◆ operator()() [1/2]

std::string SHA1::operator() ( const std::string & text)

compute SHA1 of a string, excluding final zero

Definition at line 323 of file sha1.cpp.

◆ operator()() [2/2]

std::string SHA1::operator() ( const void * data,
size_t numBytes )

compute SHA1 of a memory block

Definition at line 314 of file sha1.cpp.

◆ reset()

void SHA1::reset ( )

restart

Definition at line 25 of file sha1.cpp.


The documentation for this class was generated from the following files: