|
JubeatPlus 3.9.11
|
Message-digest helpers. More...
#include <stdbool.h>import <Foundation/Foundation.h>
Go to the source code of this file.
Functions | |
| NS_ASSUME_NONNULL_BEGIN NSString * | CreateMd5HexStringFromCString (const char *lpcszInput) |
| Hashes a NUL-terminated C string and returns the digest as a hexadecimal string. | |
| NSData * | CreateMd5DataFromCString (const char *lpcszInput) |
| Hashes a NUL-terminated C string and returns the raw 16-byte digest as data. | |
| NSString * | CreateMD5HexString (const void *pvData, unsigned int cbLength) |
| Hashes an explicit-length buffer and returns the digest as a hexadecimal string. | |
| bool | VerifyMd5Digest (const void *pvData, unsigned int cbLength, const unsigned char *pbExpectedDigest) |
| Hashes an explicit-length buffer with MD5 and compares it against an expected digest. | |
| NSString * | CreateSha256HexStringFromData (NSData *data, bool uppercase) |
Hashes an NSData with SHA-256 and returns the digest as a hexadecimal string. | |
Message-digest helpers.
Reconstructed from Ghidra program Jubeat (image base 0x100000000). All
These are among the few genuine free functions in this tree. None takes a receiver argument or belongs to a class, so the reconstruction rules' search for an owning class is exhausted and they stay free functions. Most are MD5, with one SHA-256 helper that sits beside them in the binary.
| NSData * CreateMd5DataFromCString | ( | const char * | lpcszInput | ) |
Hashes a NUL-terminated C string and returns the raw 16-byte digest as data.
Plain CommonCrypto MD5 over strlen bytes, wrapped in +[NSData dataWithBytes:length:] . Because the input is measured with strlen an embedded NUL truncates the hashed region, so this cannot hash arbitrary binary data; use CreateMD5HexString for explicit-length input.
| lpcszInput | The string to hash, as UTF-8 bytes. Not checked for nullptr . |
| NSString * CreateMD5HexString | ( | const void * | pvData, |
| unsigned int | cbLength ) |
Hashes an explicit-length buffer and returns the digest as a hexadecimal string.
The save-data integrity hash, used on both the encode and decode sides. Plain CommonCrypto MD5 over cbLength bytes, rendered as 32 lower-case hexadecimal characters. The binary unrolls the sixteen per-byte appends rather than looping.
| pvData | The bytes to hash. |
| cbLength | The byte count. |
| NS_ASSUME_NONNULL_BEGIN NSString * CreateMd5HexStringFromCString | ( | const char * | lpcszInput | ) |
Hashes a NUL-terminated C string and returns the digest as a hexadecimal string.
Plain CommonCrypto MD5 over strlen bytes, rendered as 32 lower-case hexadecimal characters. The binary unrolls the sixteen per-byte appends rather than looping.
| lpcszInput | The string to hash, as UTF-8 bytes. |
| NSString * CreateSha256HexStringFromData | ( | NSData * | data, |
| bool | uppercase ) |
Hashes an NSData with SHA-256 and returns the digest as a hexadecimal string.
Plain CommonCrypto SHA-256 over the data's explicit length, rendered as sixty-four hexadecimal characters. Hashes arbitrary binary data correctly, unlike the strlen -based MD5 helpers. The binary duplicates the whole thirty-two-iteration append loop rather than selecting the format string inside it; the two loops differ only in the per-byte format. This is the cluster's only SHA-256 user.
| data | The bytes to hash. |
| uppercase | true selects the upper-case "%02X" format, false the lower-case "%02x" . The binary tests only bit 0. |
| bool VerifyMd5Digest | ( | const void * | pvData, |
| unsigned int | cbLength, | ||
| const unsigned char * | pbExpectedDigest ) |
Hashes an explicit-length buffer with MD5 and compares it against an expected digest.
Plain CommonCrypto MD5 over cbLength bytes, whose sixteen-byte result is compared against the caller's expected digest. The comparison is byte-by-byte and short-circuits on the first mismatch, so it is not constant time: fine for detecting accidental corruption, unsuitable as an authentication check against an adversary who can time it. Unlike the strlen -based helpers above it takes an explicit length, so it hashes arbitrary binary data (including embedded NULs) correctly and is the right one for file or asset integrity checks.
| pvData | The bytes to hash. |
| cbLength | The byte count. |
| pbExpectedDigest | The expected digest. The caller must guarantee at least CC_MD5_DIGEST_LENGTH readable bytes; the length is implicit. |
true if the computed digest matches, false otherwise.