本文整理匯總了Java中org.spongycastle.crypto.digests.RIPEMD160Digest.doFinal方法的典型用法代碼示例。如果您正苦於以下問題:Java RIPEMD160Digest.doFinal方法的具體用法?Java RIPEMD160Digest.doFinal怎麽用?Java RIPEMD160Digest.doFinal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.spongycastle.crypto.digests.RIPEMD160Digest
的用法示例。
在下文中一共展示了RIPEMD160Digest.doFinal方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: hashSecret
import org.spongycastle.crypto.digests.RIPEMD160Digest; //導入方法依賴的package包/類
public static byte[] hashSecret (byte[] secret) {
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(secret);
byte[] digest = md.digest();
RIPEMD160Digest dig = new RIPEMD160Digest();
dig.update(digest, 0, digest.length);
byte[] out = new byte[20];
dig.doFinal(out, 0);
return out;
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
示例2: hashSecretToString
import org.spongycastle.crypto.digests.RIPEMD160Digest; //導入方法依賴的package包/類
public static String hashSecretToString (byte[] secret) {
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(secret);
byte[] digest = md.digest();
RIPEMD160Digest dig = new RIPEMD160Digest();
dig.update(digest, 0, digest.length);
byte[] out = new byte[20];
dig.doFinal(out, 0);
return Tools.byteToString(out);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
示例3: hashSecretToString
import org.spongycastle.crypto.digests.RIPEMD160Digest; //導入方法依賴的package包/類
/**
* Hash.java secret.
*
* @param secret the secret
* @return the string
* @throws UnsupportedEncodingException the unsupported encoding exception
* @throws NoSuchAlgorithmException the no such algorithm exception
*/
public static String hashSecretToString (byte[] secret) {
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(secret);
byte[] digest = md.digest();
RIPEMD160Digest dig = new RIPEMD160Digest();
dig.update(digest, 0, digest.length);
byte[] out = new byte[20];
dig.doFinal(out, 0);
return Tools.byteToString(out);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
示例4: sha256hash160
import org.spongycastle.crypto.digests.RIPEMD160Digest; //導入方法依賴的package包/類
/**
* Calculates RIPEMD160(SHA256(input)). This is used in Address calculations.
*/
public static byte[] sha256hash160(byte[] input) {
byte[] sha256 = Sha256Hash.hash(input);
RIPEMD160Digest digest = new RIPEMD160Digest();
digest.update(sha256, 0, sha256.length);
byte[] out = new byte[20];
digest.doFinal(out, 0);
return out;
}
示例5: calculateActualChecksum
import org.spongycastle.crypto.digests.RIPEMD160Digest; //導入方法依賴的package包/類
@Override
public byte[] calculateActualChecksum(byte[] data) {
RIPEMD160Digest ripemd160Digest = new RIPEMD160Digest();
ripemd160Digest.update(data, 0, data.length);
byte[] actualChecksum = new byte[ripemd160Digest.getDigestSize()];
ripemd160Digest.doFinal(actualChecksum, 0);
return actualChecksum;
}
示例6: sha256hash160
import org.spongycastle.crypto.digests.RIPEMD160Digest; //導入方法依賴的package包/類
/**
* Calculates RIPEMD160(SHA256(input)). This is used in Address
* calculations.
*/
public static byte[] sha256hash160(byte[] input) {
byte[] sha256 = Sha256Hash.hash(input);
RIPEMD160Digest digest = new RIPEMD160Digest();
digest.update(sha256, 0, sha256.length);
byte[] out = new byte[20];
digest.doFinal(out, 0);
return out;
}
示例7: hash160
import org.spongycastle.crypto.digests.RIPEMD160Digest; //導入方法依賴的package包/類
public static byte[] hash160(byte[] bytes) {
SHA256Digest firstDigest = new SHA256Digest();
firstDigest.update(bytes, 0, bytes.length);
byte[] firstHash = new byte[32];
firstDigest.doFinal(firstHash, 0);
RIPEMD160Digest secondDigest = new RIPEMD160Digest();
secondDigest.update(firstHash, 0, firstHash.length);
byte[] secondHash = new byte[20];
secondDigest.doFinal(secondHash, 0);
return secondHash;
}
示例8: doublehash160
import org.spongycastle.crypto.digests.RIPEMD160Digest; //導入方法依賴的package包/類
public static byte[] doublehash160(byte[] input) {
RIPEMD160Digest digest = new RIPEMD160Digest();
digest.update(input, 0, input.length);
byte[] rarr = new byte[20];
digest.doFinal(rarr, 0);
digest.reset();
digest.update(rarr, 0, rarr.length);
digest.doFinal(rarr, 0);
return rarr;
}
示例9: hash160
import org.spongycastle.crypto.digests.RIPEMD160Digest; //導入方法依賴的package包/類
/**
* This function calculates the RIPEMD160-hash of the SHA256-hash of the input to this function. This hash function is
* used to generate a Bitcoupon address from a public key.
*
* @param bytes Data to calculate hash from.
* @return RIPEMD160-hash of SHA256-hash of the input data.
*/
public static byte[] hash160(byte[] bytes) {
if (bytes == null) {
throw new IllegalArgumentException();
}
SHA256Digest firstDigest = new SHA256Digest();
firstDigest.update(bytes, 0, bytes.length);
byte[] firstHash = new byte[32];
firstDigest.doFinal(firstHash, 0);
RIPEMD160Digest secondDigest = new RIPEMD160Digest();
secondDigest.update(firstHash, 0, firstHash.length);
byte[] secondHash = new byte[20];
secondDigest.doFinal(secondHash, 0);
return secondHash;
}
示例10: RIPEMD160
import org.spongycastle.crypto.digests.RIPEMD160Digest; //導入方法依賴的package包/類
public static ByteString RIPEMD160(ByteString in)
{
RIPEMD160Digest digest = new RIPEMD160Digest();
digest.update(in.toByteArray(), 0, in.size());
byte[] out = new byte[20];
digest.doFinal(out, 0);
return ByteString.copyFrom(out);
}
示例11: getPublicAddress
import org.spongycastle.crypto.digests.RIPEMD160Digest; //導入方法依賴的package包/類
/**
* Converts a given public key to a valid MultiChain address.
* See {@link <a href="http://www.multichain.com/developers/address-key-format/">MultiChain Documentation</a>}
* @param pubKey byte array containing the public key
* @return String representing the corresponding address.
*/
public static String getPublicAddress(String[] version, String addressChecksum, byte[] pubKey) {
//Step 3
MessageDigest digest;
try {
digest = MessageDigest.getInstance("SHA-256");
digest.reset();
byte[] hash = digest.digest(pubKey);
//Step 4
RIPEMD160Digest ripemd = new RIPEMD160Digest();
ripemd.update(hash, 0, hash.length);
byte[] out = new byte[20];
ripemd.doFinal(out, 0);
String hashStr = Util.byteArrayToHexString(out);
//Step 5
String step5 = "";
if (BuildConfig.DEBUG && version.length != 4) throw new AssertionError("Version length != 4");
for (int i = 0; i < 4; i++) { //Assumes version.length == 4
step5 += version[i] + hashStr.substring((i*10),(i*10)+10);
}
digest.reset();
//Step 6
byte[] step6 = digest.digest(Util.hexStringToByteArray(step5));
digest.reset();
//Step 7
byte[] step7 = digest.digest(step6);
digest.reset();
//Step 8
byte[] checksum = new byte[]{ step7[0],step7[1],step7[2],step7[3] };
//Step 9
byte[] byteAddressChecksum = Util.hexStringToByteArray(addressChecksum);
byte[] xor = new byte[4];
for (int i = 0; i < 4; i++) {
int xorvalue = (int)checksum[i] ^ (int)byteAddressChecksum[i];
xor[i] = (byte)(0xff & xorvalue);
}
//Step 10
String addressbytes = step5 + Util.byteArrayToHexString(xor);
//Step 11
String address = Base58.encode(Util.hexStringToByteArray(addressbytes));
return address;
} catch (NoSuchAlgorithmException e1) {
e1.printStackTrace();
return null;
}
}
示例12: RIPEMD160
import org.spongycastle.crypto.digests.RIPEMD160Digest; //導入方法依賴的package包/類
public static byte[] RIPEMD160(byte[] input) {
RIPEMD160Digest d = new RIPEMD160Digest();
d.update(input, 0, input.length);
byte[] o = new byte[d.getDigestSize()];
d.doFinal(o, 0);
return o;
}