diff --git a/core-java-modules/core-java-security-3/pom.xml b/core-java-modules/core-java-security-3/pom.xml
index a4f60b4db5..ad9feeb36a 100644
--- a/core-java-modules/core-java-security-3/pom.xml
+++ b/core-java-modules/core-java-security-3/pom.xml
@@ -30,6 +30,11 @@
jaxb-api
${jaxb-api.version}
+
+ com.google.guava
+ guava
+ ${google-guava.version}
+
org.springframework.security
spring-security-crypto
@@ -39,9 +44,10 @@
1.70
- 1.11
+ 1.15
2.3.1
6.0.3
+ 31.0.1-jre
\ No newline at end of file
diff --git a/core-java-modules/core-java-security-3/src/test/java/com/baeldung/crypto/sha1/HexRepresentationSha1DigestUnitTest.java b/core-java-modules/core-java-security-3/src/test/java/com/baeldung/crypto/sha1/HexRepresentationSha1DigestUnitTest.java
new file mode 100644
index 0000000000..f2c346707e
--- /dev/null
+++ b/core-java-modules/core-java-security-3/src/test/java/com/baeldung/crypto/sha1/HexRepresentationSha1DigestUnitTest.java
@@ -0,0 +1,42 @@
+package com.baeldung.crypto.sha1;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+import org.apache.commons.codec.digest.DigestUtils;
+import org.junit.jupiter.api.Test;
+
+import com.google.common.hash.Hashing;
+
+public class HexRepresentationSha1DigestUnitTest {
+
+ String input = "Hello, World";
+ String expectedHexValue = "907d14fb3af2b0d4f18c2d46abe8aedce17367bd";
+
+ @Test
+ public void givenMessageDigest_whenUpdatingWithData_thenDigestShouldMatchExpectedValue() throws NoSuchAlgorithmException {
+ MessageDigest md = MessageDigest.getInstance("SHA-1");
+ md.update(input.getBytes(StandardCharsets.UTF_8));
+
+ StringBuilder hexString = new StringBuilder();
+ byte[] digest = md.digest();
+
+ for (byte b : digest) {
+ hexString.append(String.format("%02x", b));
+ }
+ assertEquals(expectedHexValue, hexString.toString());
+ }
+
+ @Test
+ public void givenDigestUtils_whenCalculatingSHA1Hex_thenDigestShouldMatchExpectedValue() {
+ assertEquals(expectedHexValue, DigestUtils.sha1Hex(input));
+ }
+
+ @Test
+ public void givenHashingLibrary_whenCalculatingSHA1Hash_thenDigestShouldMatchExpectedValue() {
+ assertEquals(expectedHexValue, Hashing.sha1().hashString(input, StandardCharsets.UTF_8).toString());
+ }
+}