Search in sources :

Example 6 with Digest

use of org.spongycastle.crypto.Digest in project universa by UniversaBlockchain.

the class RSAOAEPDigestFactoryTest method cloneDigest.

/**
 * Test {@link RSAOAEPDigestFactory#cloneDigest}.
 */
@Test
public void cloneDigest() throws Exception {
    Digest d1Orig = new SHA512Digest();
    Digest d1Clone = RSAOAEPDigestFactory.cloneDigest(d1Orig);
    assertTrue(d1Clone instanceof SHA512Digest);
    assertNotEquals(d1Orig, d1Clone);
}
Also used : SHA512Digest(org.spongycastle.crypto.digests.SHA512Digest) Digest(org.spongycastle.crypto.Digest) SHA512Digest(org.spongycastle.crypto.digests.SHA512Digest) Test(org.junit.Test)

Example 7 with Digest

use of org.spongycastle.crypto.Digest in project AppCoins-ethereumj by AppStoreFoundation.

the class HashUtil method ripemd160.

/**
 * @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");
}
Also used : Digest(org.spongycastle.crypto.Digest) MessageDigest(java.security.MessageDigest) RIPEMD160Digest(org.spongycastle.crypto.digests.RIPEMD160Digest) RIPEMD160Digest(org.spongycastle.crypto.digests.RIPEMD160Digest)

Aggregations

Digest (org.spongycastle.crypto.Digest)7 MessageDigest (java.security.MessageDigest)3 Test (org.junit.Test)3 RIPEMD160Digest (org.spongycastle.crypto.digests.RIPEMD160Digest)3 SHA512Digest (org.spongycastle.crypto.digests.SHA512Digest)3 SHA1Digest (org.spongycastle.crypto.digests.SHA1Digest)2 SecureRandom (java.security.SecureRandom)1 NonNull (org.checkerframework.checker.nullness.qual.NonNull)1 AsymmetricBlockCipher (org.spongycastle.crypto.AsymmetricBlockCipher)1 AsymmetricCipherKeyPair (org.spongycastle.crypto.AsymmetricCipherKeyPair)1 Signer (org.spongycastle.crypto.Signer)1 KeccakDigest (org.spongycastle.crypto.digests.KeccakDigest)1 SHA224Digest (org.spongycastle.crypto.digests.SHA224Digest)1 SHA256Digest (org.spongycastle.crypto.digests.SHA256Digest)1 OAEPEncoding (org.spongycastle.crypto.encodings.OAEPEncoding)1 RSAKeyPairGenerator (org.spongycastle.crypto.generators.RSAKeyPairGenerator)1 ParametersWithRandom (org.spongycastle.crypto.params.ParametersWithRandom)1 RSAKeyGenerationParameters (org.spongycastle.crypto.params.RSAKeyGenerationParameters)1 RSAKeyParameters (org.spongycastle.crypto.params.RSAKeyParameters)1 PSSSigner (org.spongycastle.crypto.signers.PSSSigner)1