Virgil Security Crypto library  2.6.3
VirgilByteArray.h
1 
37 #ifndef VIRGIL_BYTE_ARRAY_H
38 #define VIRGIL_BYTE_ARRAY_H
39 
40 #include <string>
41 #include <vector>
42 #include <tuple>
43 
44 namespace virgil { namespace crypto {
45 
50 typedef std::vector<unsigned char> VirgilByteArray;
51 
52 }}
53 
57 #define VIRGIL_BYTE_ARRAY_TO_PTR_AND_LEN(array) reinterpret_cast<const unsigned char *>(array.data()), array.size()
59 
60 #define VIRGIL_BYTE_ARRAY_FROM_PTR_AND_LEN(ptr, len)\
61  virgil::crypto::VirgilByteArray(reinterpret_cast<virgil::crypto::VirgilByteArray::const_pointer >(ptr), \
62  reinterpret_cast<virgil::crypto::VirgilByteArray::const_pointer >((ptr) + (len)))
63 
65 namespace virgil { namespace crypto {
66 
70 VirgilByteArray str2bytes(const std::string& str);
71 
75 std::string bytes2str(const VirgilByteArray& array);
76 
82 VirgilByteArray hex2bytes(const std::string hexStr);
83 
91 std::string bytes2hex(const VirgilByteArray& array, bool formatted = false) ;
92 
96 
100 void bytes_zeroize(VirgilByteArray& array) ;
101 
105 void string_zeroize(std::string& str);
107 
115 
122 std::tuple<VirgilByteArray, VirgilByteArray> bytes_split(const VirgilByteArray& src, size_t pos);
123 
129 std::tuple<VirgilByteArray, VirgilByteArray> bytes_split_half(const VirgilByteArray& src);
130 
137 std::vector<VirgilByteArray> bytes_split_chunks(const VirgilByteArray& src, size_t chunkSize);
138 
139 }}
140 #endif /* VIRGIL_BYTE_ARRAY_H */
VirgilByteArray str2bytes(const std::string &str)
Represents given string as byte array.
VirgilByteArray & bytes_append(VirgilByteArray &dst, const VirgilByteArray &src)
Append given source bytes to the existing destination bytes.
std::tuple< VirgilByteArray, VirgilByteArray > bytes_split_half(const VirgilByteArray &src)
Split given bytes to two sequences of the same size.
VirgilByteArray hex2bytes(const std::string hexStr)
Translate given HEX string to the byte array.
Root namespace for all Virgil Security libraries.
Definition: VirgilAsn1Compatible.h:46
std::vector< unsigned char > VirgilByteArray
This type represents a sequence of bytes.
Definition: VirgilByteArray.h:50
void bytes_zeroize(VirgilByteArray &array)
Make all bytes zero.
std::string bytes2hex(const VirgilByteArray &array, bool formatted=false)
Translate given byte array to the HEX string.
void string_zeroize(std::string &str)
Make all chars zero.
std::string bytes2str(const VirgilByteArray &array)
Represent given byte array as string.
std::vector< VirgilByteArray > bytes_split_chunks(const VirgilByteArray &src, size_t chunkSize)
Split given bytes to the chuns of the given size.
std::tuple< VirgilByteArray, VirgilByteArray > bytes_split(const VirgilByteArray &src, size_t pos)
Split given bytes to two sequences.