Java Code Examples for org.spongycastle.crypto.digests.SHA256Digest#doFinal()
The following examples show how to use
org.spongycastle.crypto.digests.SHA256Digest#doFinal() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: types.java From AndroidWallet with GNU General Public License v3.0 | 6 votes |
@Override public String toString() { byte[] data = new byte[key_data.length + 1 + 4]; data[0] = (byte) 0x80; System.arraycopy(key_data, 0, data, 1, key_data.length); SHA256Digest digest = new SHA256Digest(); digest.update(data, 0, key_data.length + 1); byte[] out = new byte[32]; digest.doFinal(out, 0); digest.update(out, 0, out.length); digest.doFinal(out, 0); System.arraycopy(out, 0, data, key_data.length + 1, 4); return Base58.encode(data); }
Example 2
Source File: types.java From guarda-android-wallets with GNU General Public License v3.0 | 6 votes |
@Override public String toString() { byte[] data = new byte[key_data.length + 1 + 4]; data[0] = (byte)0x80; System.arraycopy(key_data, 0, data, 1, key_data.length); SHA256Digest digest = new SHA256Digest(); digest.update(data, 0, key_data.length + 1); byte[] out = new byte[32]; digest.doFinal(out, 0); digest.update(out, 0, out.length); digest.doFinal(out, 0); System.arraycopy(out, 0, data, key_data.length + 1, 4); return Base58.encode(data); }
Example 3
Source File: types.java From bitshares_wallet with MIT License | 6 votes |
@Override public String toString() { byte[] data = new byte[key_data.length + 1 + 4]; data[0] = (byte)0x80; System.arraycopy(key_data, 0, data, 1, key_data.length); SHA256Digest digest = new SHA256Digest(); digest.update(data, 0, key_data.length + 1); byte[] out = new byte[32]; digest.doFinal(out, 0); digest.update(out, 0, out.length); digest.doFinal(out, 0); System.arraycopy(out, 0, data, key_data.length + 1, 4); return Base58.encode(data); }
Example 4
Source File: sha256_object.java From AndroidWallet with GNU General Public License v3.0 | 5 votes |
public static sha256_object create_from_string(String strContent) { SHA256Digest digest = new SHA256Digest(); byte[] bytePassword = strContent.getBytes(); digest.update(bytePassword, 0, bytePassword.length); byte[] byteHash = new byte[32]; digest.doFinal(byteHash, 0); sha256_object sha256Object = new sha256_object(); System.arraycopy(byteHash, 0, sha256Object.hash, 0, byteHash.length); return sha256Object; }
Example 5
Source File: types.java From AndroidWallet with GNU General Public License v3.0 | 5 votes |
public private_key_type(String strBase58) throws KeyInvalideException, AddressFormatException { byte wif_bytes[] = Base58.decode(strBase58); if (wif_bytes.length < key_data.length) { throw new KeyInvalideException("Private key is not valid"); } System.arraycopy(wif_bytes, 1, key_data, 0, key_data.length); SHA256Digest digest = new SHA256Digest(); digest.update(wif_bytes, 0, wif_bytes.length - 4); byte[] hashCheck = new byte[32]; digest.doFinal(hashCheck, 0); byte[] hashCheck2 = new byte[32]; digest.update(hashCheck, 0, hashCheck.length); digest.doFinal(hashCheck2, 0); byte check[] = new byte[4]; System.arraycopy(wif_bytes, wif_bytes.length - check.length, check, 0, check.length); byte[] check1 = new byte[4]; byte[] check2 = new byte[4]; System.arraycopy(hashCheck, 0, check1, 0, check1.length); System.arraycopy(hashCheck2, 0, check2, 0, check2.length); if (!Arrays.equals(check1, check) && !Arrays.equals(check2, check)) { throw new KeyInvalideException("Private key is not valid"); } }
Example 6
Source File: sha256_object.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
public static sha256_object create_from_string(String strContent) { SHA256Digest digest = new SHA256Digest(); byte[] bytePassword = strContent.getBytes(); digest.update(bytePassword, 0, bytePassword.length); byte[] byteHash = new byte[32]; digest.doFinal(byteHash, 0); sha256_object sha256Object = new sha256_object(); System.arraycopy(byteHash, 0, sha256Object.hash, 0, byteHash.length); return sha256Object; }
Example 7
Source File: types.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
public private_key_type(String strBase58) { byte wif_bytes[] = Base58.decode(strBase58); if (wif_bytes.length < 5) { throw new RuntimeException("Private key is not valid"); } System.arraycopy(wif_bytes, 1, key_data, 0, key_data.length); SHA256Digest digest = new SHA256Digest(); digest.update(wif_bytes, 0, wif_bytes.length - 4); byte[] hashCheck = new byte[32]; digest.doFinal(hashCheck, 0); byte[] hashCheck2 = new byte[32]; digest.update(hashCheck, 0, hashCheck.length); digest.doFinal(hashCheck2, 0); byte check[] = new byte[4]; System.arraycopy(wif_bytes, wif_bytes.length - check.length, check, 0, check.length); byte[] check1 = new byte[4]; byte[] check2 = new byte[4]; System.arraycopy(hashCheck, 0, check1, 0, check1.length); System.arraycopy(hashCheck2, 0, check2, 0, check2.length); if (Arrays.equals(check1, check) == false && Arrays.equals(check2, check) == false) { throw new RuntimeException("Private key is not valid"); } }
Example 8
Source File: sha256_object.java From bitshares_wallet with MIT License | 5 votes |
public static sha256_object create_from_string(String strContent) { SHA256Digest digest = new SHA256Digest(); byte[] bytePassword = strContent.getBytes(); digest.update(bytePassword, 0, bytePassword.length); byte[] byteHash = new byte[32]; digest.doFinal(byteHash, 0); sha256_object sha256Object = new sha256_object(); System.arraycopy(byteHash, 0, sha256Object.hash, 0, byteHash.length); return sha256Object; }
Example 9
Source File: types.java From bitshares_wallet with MIT License | 5 votes |
public private_key_type(String strBase58) { byte wif_bytes[] = Base58.decode(strBase58); if (wif_bytes.length < 5) { throw new RuntimeException("Private key is not valid"); } System.arraycopy(wif_bytes, 1, key_data, 0, key_data.length); SHA256Digest digest = new SHA256Digest(); digest.update(wif_bytes, 0, wif_bytes.length - 4); byte[] hashCheck = new byte[32]; digest.doFinal(hashCheck, 0); byte[] hashCheck2 = new byte[32]; digest.update(hashCheck, 0, hashCheck.length); digest.doFinal(hashCheck2, 0); byte check[] = new byte[4]; System.arraycopy(wif_bytes, wif_bytes.length - check.length, check, 0, check.length); byte[] check1 = new byte[4]; byte[] check2 = new byte[4]; System.arraycopy(hashCheck, 0, check1, 0, check1.length); System.arraycopy(hashCheck2, 0, check2, 0, check2.length); if (Arrays.equals(check1, check) == false && Arrays.equals(check2, check) == false) { throw new RuntimeException("Private key is not valid"); } }