summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-06-08 23:43:44 +0300
committerLinus Groh <mail@linusgroh.de>2021-06-09 11:48:04 +0100
commitb17a282b4b0a1f2831ea133b42aeec9e3d3e1208 (patch)
tree89836c67f5dd2743b9d7bd7732dd853a0b3ec52c /Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp
parent71c54198fa733efd6bfc99a73cbc024fe9bdc901 (diff)
downloadserenity-b17a282b4b0a1f2831ea133b42aeec9e3d3e1208.zip
LibCrypto: Add hash methods to {Signed, Unsigned}BigInteger
These just use hash the underlying bytes that make up the integer words
Diffstat (limited to 'Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp')
-rw-r--r--Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp
index 256cd3e923..98b91e4c3d 100644
--- a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp
+++ b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp
@@ -217,6 +217,11 @@ FLATTEN SignedDivisionResult SignedBigInteger::divided_by(const SignedBigInteger
};
}
+u32 SignedBigInteger::hash() const
+{
+ return m_unsigned_data.hash() * (1 - (2 * m_sign));
+}
+
void SignedBigInteger::set_bit_inplace(size_t bit_index)
{
m_unsigned_data.set_bit_inplace(bit_index);