sdk-world
v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Toggle main menu visibility
Loading...
Searching...
No Matches
sha256.h
Go to the documentation of this file.
1
5
// //////////////////////////////////////////////////////////
6
// sha256.h
7
// Copyright (c) 2014,2015 Stephan Brumme. All rights reserved.
8
// see http://create.stephan-brumme.com/disclaimer.html
9
//
10
11
#pragma once
12
13
//#include "hash.h"
14
#include <string>
15
16
// define fixed size integer types
17
#ifdef _MSC_VER
18
// Windows
19
typedef
unsigned
__int8 uint8_t;
20
typedef
unsigned
__int32 uint32_t;
21
typedef
unsigned
__int64 uint64_t;
22
#else
23
// GCC
24
#include <stdint.h>
25
#endif
26
27
29
41
class
SHA256
//: public Hash
42
{
43
public
:
45
enum
{ BlockSize = 512 / 8, HashBytes = 32 };
46
48
SHA256
();
49
51
std::string
operator()
(
const
void
* data,
size_t
numBytes);
53
std::string
operator()
(
const
std::string& text);
54
56
void
add
(
const
void
* data,
size_t
numBytes);
57
59
std::string
getHash
();
61
void
getHash
(
unsigned
char
buffer[HashBytes]);
62
64
void
reset
();
65
66
private
:
68
void
processBlock(
const
void
* data);
70
void
processBuffer();
71
73
uint64_t m_numBytes;
75
size_t
m_bufferSize;
77
uint8_t m_buffer[BlockSize];
78
79
enum
{ HashValues = HashBytes / 4 };
81
uint32_t m_hash[HashValues];
82
};
SHA256::add
void add(const void *data, size_t numBytes)
add arbitrary number of bytes
Definition
sha256.cpp:260
SHA256::operator()
std::string operator()(const void *data, size_t numBytes)
compute SHA256 of a memory block
Definition
sha256.cpp:416
SHA256::SHA256
SHA256()
same as reset()
Definition
sha256.cpp:20
SHA256::getHash
void getHash(unsigned char buffer[HashBytes])
return latest hash as bytes
SHA256::reset
void reset()
restart
Definition
sha256.cpp:27
SHA256::getHash
std::string getHash()
return latest hash as 64 hex characters
Definition
sha256.cpp:370
hash
include
sha256.h
Generated by
1.18.0