org.spongycastle.crypto.digests.SHA3Digest Java Examples

The following examples show how to use org.spongycastle.crypto.digests.SHA3Digest. 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: SHA3Helper.java    From wkcwallet-java with Apache License 2.0 5 votes vote down vote up
private static byte[] sha3(byte[] message, int start, int length, SHA3Digest digest, boolean bouncyencoder) {
    byte[] hash = new byte[digest.getDigestSize()];

    if (message.length != 0) {
        digest.update(message, start, length);
    }
    digest.doFinal(hash, 0);
    return hash;
}
 
Example #2
Source File: SHA3Helper.java    From ethereumj with MIT License 5 votes vote down vote up
private static byte[] doSha3(byte[] message, SHA3Digest digest, boolean bouncyencoder) {
    byte[] hash = new byte[digest.getDigestSize()];

    if (message.length != 0) {
        digest.update(message, 0, message.length);
    }
    digest.doFinal(hash, 0);
    return hash;
}
 
Example #3
Source File: SHA3Helper.java    From ethereumj with MIT License 5 votes vote down vote up
private static String sha3String(byte[] message, SHA3Digest digest, boolean bouncyencoder) {
    byte[] hash = doSha3(message, digest, bouncyencoder);
    if (bouncyencoder) {
            return Hex.toHexString(hash);
    } else {
            BigInteger bigInt = new BigInteger(1, hash);
            return bigInt.toString(16);
    }
}
 
Example #4
Source File: Sha3Hash.java    From nuls with MIT License 5 votes vote down vote up
public static byte[] sha3bytes(byte[] bytes, int bitLength) {
    Digest digest = new SHA3Digest(bitLength);
    digest.update(bytes, 0, bytes.length);
    byte[] rsData = new byte[digest.getDigestSize()];
    digest.doFinal(rsData, 0);
    return rsData;
}
 
Example #5
Source File: Sha3Hash.java    From nuls with MIT License 5 votes vote down vote up
public static String sha3(byte[] bytes, int bitLength) {
    Digest digest = new SHA3Digest(bitLength);
    digest.update(bytes, 0, bytes.length);
    byte[] rsData = new byte[digest.getDigestSize()];
    digest.doFinal(rsData, 0);
    return Hex.encode(rsData);
}
 
Example #6
Source File: SHA3Helper.java    From wkcwallet-java with Apache License 2.0 5 votes vote down vote up
private static byte[] doSha3(byte[] m1, byte[] m2, SHA3Digest digest, boolean bouncyencoder) {
    byte[] hash = new byte[digest.getDigestSize()];
    digest.update(m1, 0, m1.length);
    digest.update(m2, 0, m2.length);

    digest.doFinal(hash, 0);
    return hash;
}
 
Example #7
Source File: SHA3Helper.java    From wkcwallet-java with Apache License 2.0 5 votes vote down vote up
private static byte[] doSha3(byte[] message, SHA3Digest digest, boolean bouncyencoder) {
    byte[] hash = new byte[digest.getDigestSize()];

    if (message.length != 0) {
        digest.update(message, 0, message.length);
    }
    digest.doFinal(hash, 0);
    return hash;
}
 
Example #8
Source File: Hash.java    From neb.java with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static byte[] Sha3256(byte[]... args) {
    SHA3Digest digest = new SHA3Digest();
    for (int i = 0; i < args.length; i++) {
        byte[] bytes = args[i];
        digest.update(bytes, 0, bytes.length);
    }
    byte[] out = new byte[256 / 8];
    digest.doFinal(out, 0);
    return out;
}
 
Example #9
Source File: SHA3Helper.java    From wkcwallet-java with Apache License 2.0 5 votes vote down vote up
private static String sha3String(byte[] message, SHA3Digest digest, boolean bouncyencoder) {
    byte[] hash = doSha3(message, digest, bouncyencoder);
    if (bouncyencoder) {
        return Hex.toHexString(hash);
    } else {
        BigInteger bigInt = new BigInteger(1, hash);
        return bigInt.toString(16);
    }
}
 
Example #10
Source File: SHA3Helper.java    From ethereumj with MIT License 4 votes vote down vote up
public static String sha3String(String message) {
    return sha3String(message, new SHA3Digest(DEFAULT_SIZE), true);
}
 
Example #11
Source File: SHA3Helper.java    From wkcwallet-java with Apache License 2.0 4 votes vote down vote up
public static String sha3String(String message) {
    return sha3String(message, new SHA3Digest(DEFAULT_SIZE), true);
}
 
Example #12
Source File: SHA3Helper.java    From ethereumj with MIT License 4 votes vote down vote up
private static byte[] sha3(byte[] message, SHA3Digest digest, boolean bouncyencoder) {
    return doSha3(message, digest, bouncyencoder);
}
 
Example #13
Source File: SHA3Helper.java    From wkcwallet-java with Apache License 2.0 4 votes vote down vote up
public static String sha3String(byte[] message) {
    return sha3String(message, new SHA3Digest(DEFAULT_SIZE), true);
}
 
Example #14
Source File: SHA3Helper.java    From ethereumj with MIT License 4 votes vote down vote up
private static String sha3String(String message, SHA3Digest digest, boolean bouncyencoder) {
    if (message != null) {
            return sha3String(Hex.decode(message), digest, bouncyencoder);
    }
    throw new NullPointerException("Can't hash a NULL value");
}
 
Example #15
Source File: SHA3Helper.java    From ethereumj with MIT License 4 votes vote down vote up
protected static String sha3string(byte[] message, Size bitSize, boolean bouncyencoder) {
    SHA3Digest digest = new SHA3Digest(bitSize.bits);
    return sha3String(message, digest, bouncyencoder);
}
 
Example #16
Source File: SHA3Helper.java    From ethereumj with MIT License 4 votes vote down vote up
protected static String sha3String(String message, Size bitSize, boolean bouncyencoder) {
    SHA3Digest digest = new SHA3Digest(bitSize.bits);
    return sha3String(message, digest, bouncyencoder);
}
 
Example #17
Source File: SHA3Helper.java    From ethereumj with MIT License 4 votes vote down vote up
protected static String sha3String(byte[] message, Size bitSize) {
    SHA3Digest digest = new SHA3Digest(bitSize.bits);
    return sha3String(message, digest, true);
}
 
Example #18
Source File: SHA3Helper.java    From ethereumj with MIT License 4 votes vote down vote up
protected static String sha3String(String message, Size bitSize) {
    SHA3Digest digest = new SHA3Digest(bitSize.bits);
    return sha3String(message, digest, true);
}
 
Example #19
Source File: SHA3Helper.java    From ethereumj with MIT License 4 votes vote down vote up
public static byte[] sha3(byte[] message) {
    return sha3(message, new SHA3Digest(DEFAULT_SIZE), true);
}
 
Example #20
Source File: SHA3Helper.java    From ethereumj with MIT License 4 votes vote down vote up
public static byte[] sha3(String message) {
    return sha3(Hex.decode(message), new SHA3Digest(DEFAULT_SIZE), true);
}
 
Example #21
Source File: SHA3Helper.java    From ethereumj with MIT License 4 votes vote down vote up
public static String sha3String(byte[] message) {
    return sha3String(message, new SHA3Digest(DEFAULT_SIZE), true);
}
 
Example #22
Source File: SHA3Helper.java    From wkcwallet-java with Apache License 2.0 4 votes vote down vote up
protected static String sha3String(byte[] message, Size bitSize) {
    SHA3Digest digest = new SHA3Digest(bitSize.bits);
    return sha3String(message, digest, true);
}
 
Example #23
Source File: SHA3Helper.java    From wkcwallet-java with Apache License 2.0 4 votes vote down vote up
public static byte[] sha3(String message) {
    return sha3(Hex.decode(message), new SHA3Digest(DEFAULT_SIZE), true);
}
 
Example #24
Source File: SHA3Helper.java    From wkcwallet-java with Apache License 2.0 4 votes vote down vote up
public static byte[] sha3(byte[] message) {
    return sha3(message, new SHA3Digest(DEFAULT_SIZE), true);
}
 
Example #25
Source File: SHA3Helper.java    From wkcwallet-java with Apache License 2.0 4 votes vote down vote up
public static byte[] sha3(byte[] message, Size sz) {
    return sha3(message, new SHA3Digest(sz.bits), true);
}
 
Example #26
Source File: SHA3Helper.java    From wkcwallet-java with Apache License 2.0 4 votes vote down vote up
public static byte[] sha3(byte[] m1, byte[] m2) {
    return sha3(m1, m2, new SHA3Digest(DEFAULT_SIZE), true);
}
 
Example #27
Source File: SHA3Helper.java    From wkcwallet-java with Apache License 2.0 4 votes vote down vote up
public static byte[] sha3(byte[] message, int start, int length) {
    return sha3(message, start, length, new SHA3Digest(DEFAULT_SIZE), true);
}
 
Example #28
Source File: SHA3Helper.java    From wkcwallet-java with Apache License 2.0 4 votes vote down vote up
private static byte[] sha3(byte[] m1, byte[] m2, SHA3Digest digest, boolean bouncyencoder) {
    return doSha3(m1, m2, digest, bouncyencoder);
}
 
Example #29
Source File: SHA3Helper.java    From wkcwallet-java with Apache License 2.0 4 votes vote down vote up
private static byte[] sha3(byte[] message, SHA3Digest digest, boolean bouncyencoder) {
    return doSha3(message, digest, bouncyencoder);
}
 
Example #30
Source File: SHA3Helper.java    From wkcwallet-java with Apache License 2.0 4 votes vote down vote up
protected static String sha3String(String message, Size bitSize) {
    SHA3Digest digest = new SHA3Digest(bitSize.bits);
    return sha3String(message, digest, true);
}