Remove Helper.SHA256() method #1119

Merged
kekkyojin merged 1 commit from remove-sha256 into master 2021-01-18 20:24:23 +01:00
3 changed files with 1 additions and 25 deletions
Showing only changes of commit c08237d399 - Show all commits

View file

@ -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)));
}
}

View file

@ -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;
}
}
}

View file

@ -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)));
}
}