Merge pull request #1119 from kekkyojin/remove-sha256

Remove Helper.SHA256() method
This commit is contained in:
Akinwale Ariwodola 2021-01-18 20:24:22 +01:00 committed by GitHub
commit fdb4578349
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 25 deletions

View file

@ -8,8 +8,5 @@ import static org.junit.Assert.assertEquals;
@SmallTest @SmallTest
public class HelperTest { public class HelperTest {
@Test
public void SHA256() {
assertEquals("de9edb2044d012f04553e49b04d54cbec8e8a46a40ad5a19bc5dcce1da00ecfd", Helper.SHA256(String.valueOf(12345678912345L)));
}
} }

View file

@ -29,7 +29,6 @@ import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import org.apache.commons.codec.binary.Hex;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
@ -38,9 +37,6 @@ import org.json.JSONObject;
import java.io.Closeable; import java.io.Closeable;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
@ -791,17 +787,4 @@ public final class Helper {
return id.toString(); 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;
}
}
} }

View file

@ -4,8 +4,4 @@ import junit.framework.TestCase;
public class HelperTest extends 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)));
}
} }