From c08237d399305968cc8807e318d445e4e2ffc560 Mon Sep 17 00:00:00 2001 From: Javi Rueda Date: Thu, 14 Jan 2021 13:04:43 +0100 Subject: [PATCH] Remove Helper.SHA256() method --- .../java/io/lbry/browser/utils/HelperTest.java | 5 +---- .../main/java/io/lbry/browser/utils/Helper.java | 17 ----------------- .../java/io/lbry/browser/utils/HelperTest.java | 4 ---- 3 files changed, 1 insertion(+), 25 deletions(-) diff --git a/app/src/androidTest/java/io/lbry/browser/utils/HelperTest.java b/app/src/androidTest/java/io/lbry/browser/utils/HelperTest.java index f6caa36f..9153c63a 100644 --- a/app/src/androidTest/java/io/lbry/browser/utils/HelperTest.java +++ b/app/src/androidTest/java/io/lbry/browser/utils/HelperTest.java @@ -8,8 +8,5 @@ import static org.junit.Assert.assertEquals; @SmallTest public class HelperTest { - @Test - public void SHA256() { - assertEquals("de9edb2044d012f04553e49b04d54cbec8e8a46a40ad5a19bc5dcce1da00ecfd", Helper.SHA256(String.valueOf(12345678912345L))); - } + } diff --git a/app/src/main/java/io/lbry/browser/utils/Helper.java b/app/src/main/java/io/lbry/browser/utils/Helper.java index cd117028..7b6b4a0c 100644 --- a/app/src/main/java/io/lbry/browser/utils/Helper.java +++ b/app/src/main/java/io/lbry/browser/utils/Helper.java @@ -29,7 +29,6 @@ import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import org.apache.commons.codec.binary.Hex; import org.json.JSONArray; import org.json.JSONException; @@ -38,9 +37,6 @@ import org.json.JSONObject; import java.io.Closeable; import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -791,17 +787,4 @@ public final class Helper { return id.toString(); } - public static String SHA256(String value) { - try { - MessageDigest digest = MessageDigest.getInstance("SHA-256"); - byte[] hash = digest.digest(value.getBytes(StandardCharsets.UTF_8)); - - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O_MR1) - return Hex.encodeHexString(hash, true); - else - return new String(Hex.encodeHex(hash)).toLowerCase(); - } catch (NoSuchAlgorithmException ex) { - return null; - } - } } diff --git a/app/src/test/java/io/lbry/browser/utils/HelperTest.java b/app/src/test/java/io/lbry/browser/utils/HelperTest.java index c43b7291..7eba6a8a 100644 --- a/app/src/test/java/io/lbry/browser/utils/HelperTest.java +++ b/app/src/test/java/io/lbry/browser/utils/HelperTest.java @@ -4,8 +4,4 @@ import junit.framework.TestCase; public class HelperTest extends TestCase { - public void testSHA256() { - // Using a fake user id, which is a long. - assertEquals("de9edb2044d012f04553e49b04d54cbec8e8a46a40ad5a19bc5dcce1da00ecfd", Helper.SHA256(String.valueOf(12345678912345L))); - } } \ No newline at end of file -- 2.45.2