Merge pull request #1067 from kekkyojin/use-apache-hex

Replace Hex class from GMS with the one from Apache
This commit is contained in:
Akinwale Ariwodola 2020-12-18 12:20:42 +01:00 committed by GitHub
commit df1e8abf50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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;
}
}