當前位置: 首頁>>代碼示例>>Java>>正文


Java RIPEMD160Digest類代碼示例

本文整理匯總了Java中org.spongycastle.crypto.digests.RIPEMD160Digest的典型用法代碼示例。如果您正苦於以下問題:Java RIPEMD160Digest類的具體用法?Java RIPEMD160Digest怎麽用?Java RIPEMD160Digest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RIPEMD160Digest類屬於org.spongycastle.crypto.digests包,在下文中一共展示了RIPEMD160Digest類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
        }
    }
 
開發者ID:blockchain,項目名稱:thunder,代碼行數:20,代碼來源:Tools.java

示例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);
        }
    }
 
開發者ID:blockchain,項目名稱:thunder,代碼行數:20,代碼來源:Tools.java

示例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);
    }
}
 
開發者ID:matsjj,項目名稱:thundernetwork,代碼行數:28,代碼來源:Tools.java

示例4: ripemd160

import org.spongycastle.crypto.digests.RIPEMD160Digest; //導入依賴的package包/類
/**
 * @param data
 *            - message to hash
 * @return - reipmd160 hash of the message
 */
public static byte[] ripemd160(byte[] data) {
    Digest digest = new RIPEMD160Digest();
    if (data != null) {
        byte[] resBuf = new byte[digest.getDigestSize()];
        digest.update(data, 0, data.length);
        digest.doFinal(resBuf, 0);
        return resBuf;
    }
    throw new NullPointerException("Can't hash a NULL value");
}
 
開發者ID:talentchain,項目名稱:talchain,代碼行數:16,代碼來源:HashUtil.java

示例5: 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;
}
 
開發者ID:nuls-io,項目名稱:nuls,代碼行數:12,代碼來源:Utils.java

示例6: ripemd160

import org.spongycastle.crypto.digests.RIPEMD160Digest; //導入依賴的package包/類
/**
 * @param data - message to hash
 * @return - reipmd160 hash of the message
 */
public static byte[] ripemd160(byte[] data) {
    Digest digest = new RIPEMD160Digest();
    if (data != null) {
        byte[] resBuf = new byte[digest.getDigestSize()];
        digest.update(data, 0, data.length);
        digest.doFinal(resBuf, 0);
        return resBuf;
    }
    throw new NullPointerException("Can't hash a NULL value");
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:15,代碼來源:HashUtil.java

示例7: 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;
}
 
開發者ID:marvin-we,項目名稱:crypto-core,代碼行數:9,代碼來源:RIPEMD160ChecksumProvider.java

示例8: 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;
}
 
開發者ID:marvin-we,項目名稱:crypto-core,代碼行數:13,代碼來源:CryptoUtils.java

示例9: ripemd160

import org.spongycastle.crypto.digests.RIPEMD160Digest; //導入依賴的package包/類
/**
 * @param data - message to hash
 *
 * @return - reipmd160 hash of the message
 */
public static byte[] ripemd160(byte[] data) {
  Digest digest = new RIPEMD160Digest();
  if (data != null) {
    byte[] resBuf = new byte[digest.getDigestSize()];
    digest.update(data, 0, data.length);
    digest.doFinal(resBuf, 0);
    return resBuf;
  }
  throw new NullPointerException("Can't hash a NULL value");
}
 
開發者ID:Aptoide,項目名稱:AppCoins-ethereumj,代碼行數:16,代碼來源:HashUtil.java

示例10: 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;
}
 
開發者ID:Habitats,項目名稱:bitcoupon,代碼行數:12,代碼來源:Bitcoin.java

示例11: 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;
}
 
開發者ID:y12studio,項目名稱:bkbc-tools,代碼行數:11,代碼來源:HintScriptBuilder.java

示例12: 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;
}
 
開發者ID:bitcoupon,項目名稱:bitcoupon-bitcoin-library,代碼行數:22,代碼來源:Bitcoin.java

示例13: 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);

}
 
開發者ID:fireduck64,項目名稱:jelectrum,代碼行數:11,代碼來源:Util.java

示例14: 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;
    }
}
 
開發者ID:digital-voting-pass,項目名稱:polling-station-app,代碼行數:60,代碼來源:MultiChainAddressGenerator.java

示例15: 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;
}
 
開發者ID:emilburzo,項目名稱:brainwallet-bruteforcer,代碼行數:12,代碼來源:DigestUtil.java


注:本文中的org.spongycastle.crypto.digests.RIPEMD160Digest類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。