mirror of
https://github.com/etesync/android
synced 2024-12-22 22:58:29 +00:00
Implement sha256 using bouncy-castle.
This commit is contained in:
parent
7a80b37818
commit
94b29e86ac
@ -16,6 +16,7 @@ import org.spongycastle.crypto.paddings.PKCS7Padding;
|
||||
import org.spongycastle.crypto.paddings.PaddedBufferedBlockCipher;
|
||||
import org.spongycastle.crypto.params.KeyParameter;
|
||||
import org.spongycastle.crypto.params.ParametersWithIV;
|
||||
import org.spongycastle.jcajce.provider.digest.SHA256;
|
||||
import org.spongycastle.util.encoders.Hex;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
@ -119,13 +120,11 @@ public class Helpers {
|
||||
}
|
||||
|
||||
static String sha256(byte[] base) {
|
||||
try {
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||
byte[] hash = digest.digest(base);
|
||||
return toHex(hash);
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
SHA256Digest digest = new SHA256Digest();
|
||||
digest.update(base, 0, base.length);
|
||||
byte[] ret = new byte[digest.getDigestSize()];
|
||||
digest.doFinal(ret, 0);
|
||||
return toHex(ret);
|
||||
}
|
||||
|
||||
public static String toHex(byte[] bytes) {
|
||||
|
Loading…
Reference in New Issue
Block a user