8 #include <botan/bigint.h>
9 #include <botan/divide.h>
10 #include <botan/charset.h>
11 #include <botan/hex.h>
28 &binary[0], binary.size());
30 else if(base ==
Octal)
34 for(
size_t j = 0; j != output_size; ++j)
36 output[output_size - 1 - j] =
48 for(
size_t j = 0; j != output_size; ++j)
50 divide(copy, 10, copy, remainder);
51 output[output_size - 1 - j] =
67 encode(&output[0], n, base);
69 for(
size_t j = 0; j != output.size(); ++j)
80 const size_t n_bytes = n.
bytes();
82 throw Encoding_Error(
"encode_1363: n is too large to encode properly");
84 const size_t leading_0s = bytes - n_bytes;
114 const char buf0_with_leading_0[2] = {
'0',
static_cast<char>(buf[0]) };
117 binary +=
hex_decode(reinterpret_cast<const char*>(&buf[1]),
122 binary =
hex_decode(reinterpret_cast<const char*>(buf),
129 const size_t RADIX = ((base ==
Decimal) ? 10 : 8);
130 for(
size_t j = 0; j != length; ++j)
137 "Invalid character in decimal input");
size_t encoded_size(Base base=Binary) const
word word_at(size_t n) const
void binary_encode(byte buf[]) const
void divide(const BigInt &x, const BigInt &y_arg, BigInt &q, BigInt &r)
size_t hex_decode(byte output[], const char input[], size_t input_length, size_t &input_consumed, bool ignore_ws)
void binary_decode(const byte buf[], size_t length)
std::invalid_argument Invalid_Argument
static SecureVector< byte > encode(const BigInt &n, Base base=Binary)
static BigInt decode(const byte buf[], size_t length, Base base=Binary)
static SecureVector< byte > encode_1363(const BigInt &n, size_t bytes)
void hex_encode(char output[], const byte input[], size_t input_length, bool uppercase)