Botan

OctetString

License
Botan is released under the Simplified BSD License (see LICENSE.md)

struct  OctetStringImpl;

Octet String


const @property size_t  length();

Returns
size of this octet string in bytes

const SecureVector!ubyte  bitsOf();

Returns
this object as a SecureVector!ubyte

const @property ubyte*  ptr();

Returns
Pointer to the first ubyte of this string

const ubyte*  end();

Returns
Pointer to one past the  end of this string

const string  toString();

Returns
this encoded as hex

OctetString  opOpAssign(string op)(in OctetString other) if (op == "^");

XOR the contents of another octet string into this one

Parameters
OctetString other octet string
Returns
reference to this

void  setOddParity();

Force to have odd parity


this(in string hex_string = "");

Create a new OctetString

Parameters
string hex_string A hex encoded string

this(RandomNumberGenerator rng, size_t len);

Create a new random OctetString

Parameters
RandomNumberGenerator rng is a random number generator
size_t len is the desired length in bytes

this(const(ubyte)* input, size_t len);

Create a new OctetString

Parameters
const(ubyte)* input is an array
size_t len is the length of in in bytes

this(ALLOC)(auto ref const Vector!(ubyte, ALLOC) input);
this(ALLOC)(auto ref const RefCounted!(Vector!(ubyte, ALLOC), ALLOC) input);

Create a new OctetString

Parameters
Vector!(ubyte, ALLOC) input a bytestring

const bool  opEquals(ref const OctetString other);

Compare two strings

Parameters
OctetString other an octet string
Returns
true if x is equal to y

const int  opCmp(ref const OctetString other);

Compare two strings

Parameters
OctetString other an octet string
Returns
1 if this is bigger, -1 if smaller, 0 if equal to other

void  opOpAssign(string op)(auto ref const OctetString other) if (op == "~");

Append another OctetString to this


OctetString  opBinary(string op)(auto ref const OctetString other) if (op == "~");

Concatenate two strings

Parameters
OctetString other an octet string
Returns
this concatenated with other

OctetString  opBinary(string op)(auto ref const OctetString other) if (op == "^");

XOR two strings

Parameters
OctetString other an octet string
Returns
this XORed with other

const @property OctetString  dup();

Returns
A copy of the underlying bits in a new octet string

alias  SymmetricKey = memutils.refcounted.RefCounted!(OctetStringImpl, ThreadMem).RefCounted;

Alternate name for octet string showing intent to use as a key


alias  InitializationVector = memutils.refcounted.RefCounted!(OctetStringImpl, ThreadMem).RefCounted;

Alternate name for octet string showing intent to use as an IV