CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
hash::Keccak Class Reference

compute Keccak hash (designated SHA3) More...

#include <keccak.h>

Public Types

enum  Bits { Keccak224 = 224 , Keccak256 = 256 , Keccak384 = 384 , Keccak512 = 512 }
 algorithm variants More...

Public Member Functions

 Keccak (Bits bits=Keccak256)
 same as reset()
std::string operator() (const void *data, size_t numBytes)
 compute hash of a memory block
std::string operator() (const std::string &text)
 compute hash 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 hex characters
void reset ()
 restart

Detailed Description

compute Keccak hash (designated SHA3)

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

or in a streaming fashion:

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

Definition at line 43 of file keccak.h.

Member Enumeration Documentation

◆ Bits

algorithm variants

Enumerator
Keccak224 
Keccak256 
Keccak384 
Keccak512 

Definition at line 47 of file keccak.h.

Constructor & Destructor Documentation

◆ Keccak()

hash::Keccak::Keccak ( Bits bits = Keccak256)
explicit

same as reset()

Definition at line 25 of file keccak.cpp.

References reset().

Member Function Documentation

◆ add()

void hash::Keccak::add ( const void * data,
size_t numBytes )

add arbitrary number of bytes

Definition at line 181 of file keccak.cpp.

Referenced by operator()(), and operator()().

◆ getHash()

std::string hash::Keccak::getHash ( )

return latest hash as hex characters

return latest hash as 16 hex characters

Definition at line 245 of file keccak.cpp.

Referenced by operator()(), and operator()().

◆ operator()() [1/2]

std::string hash::Keccak::operator() ( const std::string & text)

compute hash of a string, excluding final zero

compute Keccak hash of a string, excluding final zero

Definition at line 293 of file keccak.cpp.

References add(), getHash(), and reset().

◆ operator()() [2/2]

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

compute hash of a memory block

compute Keccak hash of a memory block

Definition at line 284 of file keccak.cpp.

References add(), getHash(), and reset().

◆ reset()

void hash::Keccak::reset ( )

restart

Definition at line 34 of file keccak.cpp.

Referenced by Keccak(), operator()(), and operator()().


The documentation for this class was generated from the following files:
  • /home/ubuntu/c/partner/psyclone2/CMSDK/include/hash/keccak.h
  • /home/ubuntu/c/partner/psyclone2/CMSDK/src/hash/keccak.cpp