Remove Helper.SHA256() method
This commit is contained in:
parent
bdf8a58818
commit
c08237d399
3 changed files with 1 additions and 25 deletions
|
@ -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)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)));
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue