From 4d0ad474919253ce7e055802fd89692b7d30deb2 Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 13 Feb 2023 13:45:06 -0500 Subject: [PATCH] GetBit for IdentHash --- libi2pd/Tag.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libi2pd/Tag.h b/libi2pd/Tag.h index d898395f..d0b0c056 100644 --- a/libi2pd/Tag.h +++ b/libi2pd/Tag.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2013-2022, The PurpleI2P Project +* Copyright (c) 2013-2023, The PurpleI2P Project * * This file is part of Purple i2pd project and licensed under BSD3 * @@ -80,6 +80,13 @@ namespace data { return i2p::data::Base64ToByteStream (s.c_str (), s.length (), m_Buf, sz); } + uint8_t GetBit (int i) const + { + int pos = i >> 3; // /8 + if (pos >= sz) return 0; + return m_Buf[pos] & (1 << (7 - (i & 0x07))); + } + private: union // 8 bytes aligned