From a3241065c55fd2a69e8793b89a5d0b1a957b3fd0 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 10 Oct 2023 21:14:50 +0100 Subject: Start migrating to range-based for loops. --- modules/encryption/enc_bcrypt.cpp | 4 ++-- modules/encryption/enc_sha256.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'modules/encryption') diff --git a/modules/encryption/enc_bcrypt.cpp b/modules/encryption/enc_bcrypt.cpp index 7eec04ad2..94c6fc164 100644 --- a/modules/encryption/enc_bcrypt.cpp +++ b/modules/encryption/enc_bcrypt.cpp @@ -20,8 +20,8 @@ class EBCRYPT : public Module Anope::string Salt() { char entropy[16]; - for (unsigned int i = 0; i < sizeof(entropy); i++) - entropy[i] = static_cast(rand() % 0xFF); + for (auto &chr : entropy) + chr = static_cast(rand() % 0xFF); char salt[32]; if (!_crypt_gensalt_blowfish_rn("$2a$", rounds, entropy, sizeof(entropy), salt, sizeof(salt))) diff --git a/modules/encryption/enc_sha256.cpp b/modules/encryption/enc_sha256.cpp index 878598248..d5cebcb74 100644 --- a/modules/encryption/enc_sha256.cpp +++ b/modules/encryption/enc_sha256.cpp @@ -245,8 +245,8 @@ class ESHA256 : public Module /* initializes the IV with a new random value */ void NewRandomIV() { - for (int i = 0; i < 8; ++i) - iv[i] = static_cast(rand()); + for (auto &ivsegment : iv) + ivsegment = static_cast(rand()); } /* returns the IV as base64-encrypted string */ -- cgit