diff options
| author | Shauren <shauren.trinity@gmail.com> | 2024-11-14 00:13:18 +0100 |
|---|---|---|
| committer | Ovahlord <dreadkiller@gmx.de> | 2024-11-14 00:30:53 +0100 |
| commit | dcc59a3d9998f033dfabab81d334382ceb7e98b0 (patch) | |
| tree | 46a2dc7ce0bc26013284bc34507c297410bc2a7e /src/common/Cryptography | |
| parent | 36bece3fc53d1535abd38217908c3042c68dfa2a (diff) | |
Core/Misc: Support IPv6 ip2location
(cherry picked from commit c522e5f4c22b53b349b05486fa28cdf58f4ffc26)
Diffstat (limited to 'src/common/Cryptography')
| -rw-r--r-- | src/common/Cryptography/BigNumber.cpp | 6 | ||||
| -rw-r--r-- | src/common/Cryptography/BigNumber.h | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/common/Cryptography/BigNumber.cpp b/src/common/Cryptography/BigNumber.cpp index f220ca319be..66071006a7f 100644 --- a/src/common/Cryptography/BigNumber.cpp +++ b/src/common/Cryptography/BigNumber.cpp @@ -61,6 +61,12 @@ void BigNumber::SetBinary(uint8 const* bytes, int32 len, bool littleEndian) BN_bin2bn(bytes, len, _bn); } +bool BigNumber::SetDecStr(char const* str) +{ + int n = BN_dec2bn(&_bn, str); + return n > 0; +} + bool BigNumber::SetHexStr(char const* str) { int n = BN_hex2bn(&_bn, str); diff --git a/src/common/Cryptography/BigNumber.h b/src/common/Cryptography/BigNumber.h index 3ec6cc65590..3815339d9cf 100644 --- a/src/common/Cryptography/BigNumber.h +++ b/src/common/Cryptography/BigNumber.h @@ -46,6 +46,8 @@ class TC_COMMON_API BigNumber void SetBinary(uint8 const* bytes, int32 len, bool littleEndian = true); template <typename Container> auto SetBinary(Container const& c, bool littleEndian = true) -> std::enable_if_t<!std::is_pointer_v<std::decay_t<Container>>> { SetBinary(std::data(c), std::size(c), littleEndian); } + bool SetDecStr(char const* str); + bool SetDecStr(std::string const& str) { return SetDecStr(str.c_str()); } bool SetHexStr(char const* str); bool SetHexStr(std::string const& str) { return SetHexStr(str.c_str()); } |
