Skip to content

Commit 54d6f9b

Browse files
name refactoring
1 parent 5a2f820 commit 54d6f9b

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ int main() {
105105

106106
## How to use? (Hash with HMAC SHA-256)
107107

108-
All you need to do is call the **"hashByHmacSha256"** function to hash the given text by given secret key with HMAC SHA-256.
108+
All you need to do is call the **"hmacSha256"** function to hash the given text by given secret key with HMAC SHA-256.
109109

110110
```cpp
111111
#include "libcpp-crypto.hpp"
@@ -118,7 +118,7 @@ int main() {
118118

119119
const auto key = "mySecretKey";
120120

121-
const auto hashedText = CryptoService::hashByHmacSha256(plainText, key);
121+
const auto hashedText = CryptoService::hmacSha256(plainText, key);
122122

123123
std::cout << "Hash: " << hashedText << std::endl;
124124

examples/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ void hashByHmacSha256()
257257
const auto plainText = "This text will be hashed soon";
258258
const auto key = "mySecretKey";
259259

260-
const auto hashText = CryptoService::hashByHmacSha256(plainText, key);
260+
const auto hashText = CryptoService::hmacSha256(plainText, key);
261261

262262
std::cout << "Hash: " << hashText << std::endl;
263263
}

src/libcpp-crypto.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ namespace lklibs
745745
*
746746
* @return Hashed string
747747
*/
748-
inline std::string hashByHmacSha256(const std::string& plainText, const std::string& key)
748+
inline std::string hmacSha256(const std::string& plainText, const std::string& key)
749749
{
750750
const auto keyBytes = reinterpret_cast<const unsigned char*>(key.c_str());
751751
const size_t keyLength = key.length();

test/test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,12 +494,12 @@ TEST(HashTest, HashWithSHA256MustBeCompletedSuccessfully)
494494
ASSERT_EQ(hashText, "d32448bab2777b376a5592e384146c3c0182ba589e2521bd0275f2cef6a50546") << "Hash is invalid";
495495
}
496496

497-
TEST(HashByHmacSha256Test, HashWithHMACSHA256MustBeCompletedSuccessfully)
497+
TEST(HmacSha256Test, HashWithHMACSHA256MustBeCompletedSuccessfully)
498498
{
499499
const auto plainText = "This text will be hashed soon";
500500
const auto key = "mySecretKey";
501501

502-
const auto hashText = CryptoService::hashByHmacSha256(plainText, key);
502+
const auto hashText = CryptoService::hmacSha256(plainText, key);
503503

504504
ASSERT_EQ(hashText, "875dae56af4cb9c9c1b2e7f30e28704da4f1933bf85bb180409761f9c4721186") << "Hash is invalid";
505505
}

0 commit comments

Comments
 (0)