From f18d49db483b0dc9d8f8371b538dd8f7d506a419 Mon Sep 17 00:00:00 2001 From: sehraf Date: Sat, 13 Jun 2020 11:07:07 +0200 Subject: [PATCH] use RsRandom::alphaNumeric --- libretroshare/src/services/autoproxy/p3i2pbob.cc | 10 +++------- libretroshare/src/util/i2pcommon.cpp | 8 -------- libretroshare/src/util/i2pcommon.h | 13 ------------- 3 files changed, 3 insertions(+), 28 deletions(-) diff --git a/libretroshare/src/services/autoproxy/p3i2pbob.cc b/libretroshare/src/services/autoproxy/p3i2pbob.cc index a170d08ca..f9eb3d9b3 100644 --- a/libretroshare/src/services/autoproxy/p3i2pbob.cc +++ b/libretroshare/src/services/autoproxy/p3i2pbob.cc @@ -945,13 +945,9 @@ void p3I2pBob::finalizeSettings_locked() // setup commands // new lines are appended later! - // generate random suffix for name - // RSRandom::random_alphaNumericString can return very weird looking strings like: ,,@z+M - // use base32 instead - size_t len = 5; // 5 characters = 8 base32 symbols - std::vector tmp(len); - RSRandom::random_bytes(tmp.data(), len); - const std::string location = Radix32::encode(tmp.data(), len); + // generate 8 characater long random suffix for name + constexpr size_t len = 8; + const std::string location = RsRandom::alphaNumeric(len); RS_DBG4("using suffix ", location); mTunnelName = "RetroShare-" + location; diff --git a/libretroshare/src/util/i2pcommon.cpp b/libretroshare/src/util/i2pcommon.cpp index eef359576..ec2ebfd6b 100644 --- a/libretroshare/src/util/i2pcommon.cpp +++ b/libretroshare/src/util/i2pcommon.cpp @@ -5,14 +5,6 @@ namespace i2p { -const std::string generateNameSuffix(const size_t len) { - std::vector tmp(len); - RsRandom::random_bytes(tmp.data(), len); - const std::string location = Radix32::encode(tmp.data(), len); - - return location; -} - std::string keyToBase32Addr(const std::string &key) { std::string copy(key); diff --git a/libretroshare/src/util/i2pcommon.h b/libretroshare/src/util/i2pcommon.h index 63f1ba5af..01d655bf9 100644 --- a/libretroshare/src/util/i2pcommon.h +++ b/libretroshare/src/util/i2pcommon.h @@ -184,19 +184,6 @@ static const std::array, 12> signingKeyLengths { /*SigningKeyType::RedDSA_SHA512_Ed25519 */ std::make_pair( 32, 32), }; - -/** - * @brief generateNameSuffix Generates a base32 name suffix for tunnel identification - * @param len lenght of random bytes, will be expanded by base32 encoding - * @return base32 string - * - * RSRandom::random_alphaNumericString can return very weird looking strings like: ,,@z+M - * -> so use base32 instead - * - * 5 characters = 8 base32 symbols - */ -const std::string generateNameSuffix(const size_t len = 5); - /** * @brief makeOption Creates the string "lhs=rhs" used by BOB and SAM. Converts rhs * @param lhs option to set