1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 23:37:35 +00:00

LibCrypto: Replace from_base{2,8,10,16}() & to_base10 with from_base(N)

This allows us to support parsing and serializing BigIntegers to and
from any base N (such that 2 <= N <= 36).
This commit is contained in:
Idan Horowitz 2021-06-29 17:51:52 +03:00 committed by Linus Groh
parent a768131720
commit 005d75656e
14 changed files with 56 additions and 132 deletions

View file

@ -53,11 +53,8 @@ public:
size_t export_data(Bytes, bool remove_leading_zeros = false) const;
static UnsignedBigInteger from_base2(const String& str);
static UnsignedBigInteger from_base8(const String& str);
static UnsignedBigInteger from_base10(const String& str);
String to_base10() const;
static UnsignedBigInteger from_base16(const String& str);
static UnsignedBigInteger from_base(u16 N, const String& str);
String to_base(u16 N) const;
u64 to_u64() const;
@ -131,5 +128,5 @@ struct AK::Formatter<Crypto::UnsignedBigInteger> : Formatter<StringView> {
inline Crypto::UnsignedBigInteger
operator""_bigint(const char* string, size_t length)
{
return Crypto::UnsignedBigInteger::from_base10({ string, length });
return Crypto::UnsignedBigInteger::from_base(10, { string, length });
}