Crypt

Various hash and encode/decode functions.

Namespace: dmCrypt
Include: #include <>
ENUMS
Algorithm encryption algorithm enumeration
Result result enumeration
FUNCTIONS
bool dmCrypt::Base64Decode(const uint8_t* src, uint32_t src_len, uint8_t* dst, uint32_t* dst_len[in,out]) Base64 decode a buffer
bool dmCrypt::Base64Encode(const uint8_t* src, uint32_t src_len, uint8_t* dst, uint32_t* dst_len[in,out]) Base64 encode a buffer
dmCrypt::Result dmCrypt::Decrypt(dmCrypt::Algorithm algo, const uint8_t* data, uint32_t datalen, const uint8_t* key, uint32_t keylen) Decrypt data in place
dmCrypt::Result dmCrypt::Encrypt(dmCrypt::Algorithm algo, const uint8_t* data, uint32_t datalen, const uint8_t* key, uint32_t keylen) Encrypt data in place
void dmCrypt::HashMd5(const uint8_t* buf, uint32_t buflen, const uint8_t* digest) Hash buffer using MD5
void dmCrypt::HashSha1(const uint8_t* buf, uint32_t buflen, uint8_t* digest) Hash buffer using SHA1
void dmCrypt::HashSha256(const uint8_t* buf, uint32_t buflen, uint8_t* digest) Hash buffer using SHA256
void dmCrypt::HashSha512(const uint8_t* buf, uint32_t buflen, uint8_t* digest) Hash buffer using SHA512

Functions

dmCrypt::Base64Decode

bool dmCrypt::Base64Decode(const uint8_t* src, uint32_t src_len, uint8_t* dst, uint32_t* dst_len[in,out])

Base64 decode a buffer

PARAMETERS

const uint8_t* src The source data to encode
uint32_t src_len key The length of source data in bytes
uint8_t* dst The destination buffer
uint32_t* dst_len[in,out] In: The length of the destination in bytes. Out: The length of the decoded string.

RETURNS

bool true if the decoding went ok

dmCrypt::Base64Encode

bool dmCrypt::Base64Encode(const uint8_t* src, uint32_t src_len, uint8_t* dst, uint32_t* dst_len[in,out])

Base64 encode a buffer

PARAMETERS

const uint8_t* src The source data to encode
uint32_t src_len key The length of source data in bytes
uint8_t* dst The destination buffer
uint32_t* dst_len[in,out] In: The length of the destination in bytes. Out: The length of the encoded string.

RETURNS

bool true if the encoding went ok

dmCrypt::Decrypt

dmCrypt::Result dmCrypt::Decrypt(dmCrypt::Algorithm algo, const uint8_t* data, uint32_t datalen, const uint8_t* key, uint32_t keylen)

Decrypt data in place

PARAMETERS

dmCrypt::Algorithm algo algorithm
const uint8_t* data data
uint32_t datalen data length in bytes
const uint8_t* key key
uint32_t keylen key length

RETURNS

dmCrypt::Result the decryption result

dmCrypt::Encrypt

dmCrypt::Result dmCrypt::Encrypt(dmCrypt::Algorithm algo, const uint8_t* data, uint32_t datalen, const uint8_t* key, uint32_t keylen)

Encrypt data in place

PARAMETERS

dmCrypt::Algorithm algo algorithm
const uint8_t* data data
uint32_t datalen data length in bytes
const uint8_t* key key
uint32_t keylen key length

RETURNS

dmCrypt::Result the encryption result

dmCrypt::HashMd5

void dmCrypt::HashMd5(const uint8_t* buf, uint32_t buflen, const uint8_t* digest)

Hash buffer using MD5

PARAMETERS

const uint8_t* buf The source data to hash
uint32_t buflen key The length of source data in bytes
const uint8_t* digest The destination buffer (16 bytes)

dmCrypt::HashSha1

void dmCrypt::HashSha1(const uint8_t* buf, uint32_t buflen, uint8_t* digest)

Hash buffer using SHA1

PARAMETERS

const uint8_t* buf The source data to hash
uint32_t buflen The length of source data in bytes
uint8_t* digest The destination buffer (20 bytes)

dmCrypt::HashSha256

void dmCrypt::HashSha256(const uint8_t* buf, uint32_t buflen, uint8_t* digest)

Hash buffer using SHA256

PARAMETERS

const uint8_t* buf The source data to hash
uint32_t buflen key The length of source data in bytes
uint8_t* digest The destination buffer (32 bytes)

dmCrypt::HashSha512

void dmCrypt::HashSha512(const uint8_t* buf, uint32_t buflen, uint8_t* digest)

Hash buffer using SHA512

PARAMETERS

const uint8_t* buf The source data to hash
uint32_t buflen key The length of source data in bytes
uint8_t* digest The destination buffer (64 bytes)

Enums

Algorithm

encryption algorithm enumeration

dmCrypt::ALGORITHM_XTEA

Result

result enumeration

dmCrypt::RESULT_OK = 0
dmCrypt::RESULT_ERROR = 1