Virgil Security Crypto library  2.6.3
Static Public Member Functions | List of all members
virgil::crypto::VirgilByteArrayUtils Class Reference

This class contains conversion utils for byte sequence. More...

#include <VirgilByteArrayUtils.h>

Static Public Member Functions

static VirgilByteArray jsonToBytes (const std::string &json)
 Represents given JSON object as byte array in canonical form. More...
 
static VirgilByteArray stringToBytes (const std::string &str)
 Represents given string as byte array.
 
static std::string bytesToString (const VirgilByteArray &array)
 Represent given byte array as string.
 
static VirgilByteArray hexToBytes (const std::string &hexStr)
 Translate given HEX string to the byte array. More...
 
static std::string bytesToHex (const VirgilByteArray &array, bool formatted=false)
 Translate given byte array to the HEX string. More...
 
static void zeroize (VirgilByteArray &array)
 Make all bytes zero. More...
 
static void append (VirgilByteArray &dst, const VirgilByteArray &src)
 Append given bytes to the existing one. More...
 
static VirgilByteArray popBytes (VirgilByteArray &src, size_t num)
 Return first num bytes and remove it from the src.
 

Detailed Description

This class contains conversion utils for byte sequence.

Member Function Documentation

static void virgil::crypto::VirgilByteArrayUtils::append ( VirgilByteArray dst,
const VirgilByteArray src 
)
static

Append given bytes to the existing one.

Parameters
dst- destination.
src- source.
static std::string virgil::crypto::VirgilByteArrayUtils::bytesToHex ( const VirgilByteArray array,
bool  formatted = false 
)
static

Translate given byte array to the HEX string.

Parameters
array- byte array.
formatted- if true, endline will be inserted every 16 bytes, and all bytes will be separated with whitespaces.
Returns
HEX string.
static VirgilByteArray virgil::crypto::VirgilByteArrayUtils::hexToBytes ( const std::string &  hexStr)
static

Translate given HEX string to the byte array.

Parameters
hexStr- HEX string.
Returns
Byte array.
static VirgilByteArray virgil::crypto::VirgilByteArrayUtils::jsonToBytes ( const std::string &  json)
static

Represents given JSON object as byte array in canonical form.

Exceptions
VirgilCryptoExceptionwith VirgilCryptoError::InvalidFormat, if JSON is invalid.
VirgilCryptoExceptionwith VirgilCryptoError::InvalidArgument, if JSON contains unsupported data types: i.e. double.
Note
Conversion it to canonical form, ensure the same digest of JSON object, that can be differently formatted.
This method SHOULD be used before sign of JSON data object.
Underlying canonical representation is ASN.1, but it can be changed in the future.
static void virgil::crypto::VirgilByteArrayUtils::zeroize ( VirgilByteArray array)
static

Make all bytes zero.

This method SHOULD be used to securely delete sensitive data.


The documentation for this class was generated from the following file: