Replace Hex class from GMS with the one from Apache

This commit is contained in:
Javi Rueda 2020-12-14 18:17:13 +01:00
parent c1324efb41
commit 601031e55d
2 changed files with 6 additions and 6 deletions

View file

@ -119,6 +119,7 @@ dependencies {
implementation 'com.arthenica:mobile-ffmpeg-full-gpl:4.3.1.LTS'
implementation 'commons-codec:commons-codec:1.15'
implementation 'org.bitcoinj:bitcoinj-tools:0.14.7'
implementation 'org.java-websocket:Java-WebSocket:1.5.1'

View file

@ -29,9 +29,8 @@ import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.gms.common.util.Hex;
import org.apache.commons.codec.binary.Hex;
import org.bitcoinj.core.Base58;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@ -39,7 +38,7 @@ import org.json.JSONObject;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.DecimalFormat;
@ -795,9 +794,9 @@ public final class Helper {
public static String SHA256(String value) {
try {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(value.getBytes("UTF-8"));
return Hex.bytesToStringLowercase(hash);
} catch (NoSuchAlgorithmException | UnsupportedEncodingException ex) {
byte[] hash = digest.digest(value.getBytes(StandardCharsets.UTF_8));
return Hex.encodeHexString(hash, true);
} catch (NoSuchAlgorithmException ex) {
return null;
}
}