Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

This repository contains cryptography utility functions.

random.h

This file includes the function GenerateCryptographicallySecureRandomNumber, which generates random bytes.

Currently supported platforms are Linux and Apple. The entropy level of this random bytes depends on the machine; if the machine has high entropy, the generated bytes will also have high entropy.

The method uses /dev/urandom which is assumed to be cryptographically secure.

Usage:

To use this function, include crypto-utils/random.h.

#include "crypto-utils/random.h"

size_t num_bytes = 16;  
std::vector<unsigned char> random_bytes = GenerateCryptographicallySecureRandomNumber(num_bytes);

The function GenerateCryptographicallySecureRandomNumber takes a single parameter of type size_t, which specifies the number of random bytes to generate.

It returns a std::vector<unsigned char> containing the generated random bytes as elements in the vector.


hex.h

This file contains two functions:

  • to_hex: Takes a std::vector<unsigned char> and returns its hexadecimal string representation.
  • from_hex: Takes a hexadecimal string and converts it into a std::vector<unsigned char>.
Usage:

To use these functions, include crypto-utils/hex.h.

#include "crypto-utils/hex.h"

std::string msg("hi");
std::vector<unsigned char> data(msg.begin(), message.end());  
std::string hex_string = to_hex(data);  

std::vector<unsigned char> decoded_data = from_hex(hex_string);  

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages