src/org/kocakosm/pitaya/security/Factory.java
static Digest newDigest(Algorithm<Digest> algorithm)
	{
		Parameters.checkNotNull(algorithm);
		Digest digest;
		if (algorithm == Algorithm.MD2) {
			digest = Digests.md2();
		} else if (algorithm == Algorithm.MD4) {
			digest = Digests.md4();
		} else if (algorithm == Algorithm.MD5) {
			digest = Digests.md5();
		} else if (algorithm == Algorithm.SHA1) {
			digest = Digests.sha1();
		} else if (algorithm == Algorithm.SHA256) {
			digest = Digests.sha256();
		} else if (algorithm == Algorithm.SHA512) {
			digest = Digests.sha512();
		} else if (algorithm == Algorithm.KECCAK224) {
			digest = Digests.keccak224();
		} else if (algorithm == Algorithm.KECCAK256) {
			digest = Digests.keccak256();
		} else if (algorithm == Algorithm.KECCAK384) {
			digest = Digests.keccak384();
		} else if (algorithm == Algorithm.KECCAK512) {
			digest = Digests.keccak512();
		} else {
			throw new IllegalArgumentException("Unknown algorithm");
		}
		return digest;
	}
static Digest newDigest(Algorithm<Digest> algorithm)
	{
		Parameters.checkNotNull(algorithm);
		Digest digest;
		if (algorithm == Algorithm.MD2) {
			digest = Digests.md2();
		} else if (algorithm == Algorithm.MD4) {
			digest = Digests.md4();
		} else if (algorithm == Algorithm.MD5) {
			digest = Digests.md5();
		} else if (algorithm == Algorithm.SHA1) {
			digest = Digests.sha1();
		} else if (algorithm == Algorithm.SHA256) {
			digest = Digests.sha256();
		} else if (algorithm == Algorithm.SHA512) {
			digest = Digests.sha512();
		} else if (algorithm == Algorithm.KECCAK224) {
			digest = Digests.keccak224();
		} else if (algorithm == Algorithm.KECCAK256) {
			digest = Digests.keccak256();
		} else if (algorithm == Algorithm.KECCAK384) {
			digest = Digests.keccak384();
		} else if (algorithm == Algorithm.KECCAK512) {
			digest = Digests.keccak512();
		} else {
			throw new IllegalArgumentException("Unknown algorithm");
		}
		return digest;
	}
static Digest newDigest ( Algorithm < Digest > algorithm ) { Parameters . checkNotNull ( algorithm ) ; Digest digest ; if ( algorithm == Algorithm . MD2 ) { digest = Digests . md2 ( ) ; } else if ( algorithm == Algorithm . MD4 ) { digest = Digests . md4 ( ) ; } else if ( algorithm == Algorithm . MD5 ) { digest = Digests . md5 ( ) ; } else if ( algorithm == Algorithm . SHA1 ) { digest = Digests . sha1 ( ) ; } else if ( algorithm == Algorithm . SHA256 ) { digest = Digests . sha256 ( ) ; } else if ( algorithm == Algorithm . SHA512 ) { digest = Digests . sha512 ( ) ; } else if ( algorithm == Algorithm . KECCAK224 ) { digest = Digests . keccak224 ( ) ; } else if ( algorithm == Algorithm . KECCAK256 ) { digest = Digests . keccak256 ( ) ; } else if ( algorithm == Algorithm . KECCAK384 ) { digest = Digests . keccak384 ( ) ; } else if ( algorithm == Algorithm . KECCAK512 ) { digest = Digests . keccak512 ( ) ; } else { throw new IllegalArgumentException ( "Unknown algorithm" ) ; } return digest ; }
Creates and returns a {@link Digest} instance corresponding to the
given algorithm.

@param algorithm the digest algorithm.

@return the created {@link Digest} instance.

@throws NullPointerException if {@code algorithm} is {@code null}.
@throws IllegalArgumentException if the given algorithm is unknown.
Creates and returns a { @link Digest } instance corresponding to the given algorithm .