Replace Hex class from GMS with the one from Apache #1067

Merged
kekkyojin merged 1 commit from use-apache-hex into master 2020-12-18 12:20:43 +01:00
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 '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.bitcoinj:bitcoinj-tools:0.14.7'
implementation 'org.java-websocket:Java-WebSocket:1.5.1' 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.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; 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.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -39,7 +38,7 @@ 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.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.text.DecimalFormat; import java.text.DecimalFormat;
@ -795,9 +794,9 @@ public final class Helper {
public static String SHA256(String value) { public static String SHA256(String value) {
try { try {
MessageDigest digest = MessageDigest.getInstance("SHA-256"); MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(value.getBytes("UTF-8")); byte[] hash = digest.digest(value.getBytes(StandardCharsets.UTF_8));
return Hex.bytesToStringLowercase(hash); return Hex.encodeHexString(hash, true);
} catch (NoSuchAlgorithmException | UnsupportedEncodingException ex) { } catch (NoSuchAlgorithmException ex) {
return null; return null;
} }
} }