当前位置: 首页>>代码示例>>Java>>正文


Java MD5Digest类代码示例

本文整理汇总了Java中org.bouncycastle.crypto.digests.MD5Digest的典型用法代码示例。如果您正苦于以下问题:Java MD5Digest类的具体用法?Java MD5Digest怎么用?Java MD5Digest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MD5Digest类属于org.bouncycastle.crypto.digests包,在下文中一共展示了MD5Digest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createHash

import org.bouncycastle.crypto.digests.MD5Digest; //导入依赖的package包/类
public static final Digest createHash(int hashAlgorithm)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return new MD5Digest();
    case HashAlgorithm.sha1:
        return new SHA1Digest();
    case HashAlgorithm.sha224:
        return new SHA224Digest();
    case HashAlgorithm.sha256:
        return new SHA256Digest();
    case HashAlgorithm.sha384:
        return new SHA384Digest();
    case HashAlgorithm.sha512:
        return new SHA512Digest();
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:21,代码来源:TlsUtils.java

示例2: OldPKCS12ParametersGenerator

import org.bouncycastle.crypto.digests.MD5Digest; //导入依赖的package包/类
/**
 * Construct a PKCS 12 Parameters generator. This constructor will
 * accept MD5, SHA1, and RIPEMD160.
 *
 * @param digest the digest to be used as the source of derived keys.
 * @exception IllegalArgumentException if an unknown digest is passed in.
 */
public OldPKCS12ParametersGenerator(
    Digest  digest)
{
    this.digest = digest;
    if (digest instanceof MD5Digest)
    {
        u = 128 / 8;
        v = 512 / 8;
    }
    else if (digest instanceof SHA1Digest)
    {
        u = 160 / 8;
        v = 512 / 8;
    }
    else if (digest instanceof RIPEMD160Digest)
    {
        u = 160 / 8;
        v = 512 / 8;
    }
    else
    {
        throw new IllegalArgumentException("Digest " + digest.getAlgorithmName() + " unsupported");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:32,代码来源:BrokenPBE.java

示例3: PRF_legacy

import org.bouncycastle.crypto.digests.MD5Digest; //导入依赖的package包/类
static byte[] PRF_legacy(byte[] secret, byte[] label, byte[] labelSeed, int size)
{
    int s_half = (secret.length + 1) / 2;
    byte[] s1 = new byte[s_half];
    byte[] s2 = new byte[s_half];
    System.arraycopy(secret, 0, s1, 0, s_half);
    System.arraycopy(secret, secret.length - s_half, s2, 0, s_half);

    byte[] b1 = new byte[size];
    byte[] b2 = new byte[size];
    hmac_hash(new MD5Digest(), s1, labelSeed, b1);
    hmac_hash(new SHA1Digest(), s2, labelSeed, b2);
    for (int i = 0; i < size; i++)
    {
        b1[i] ^= b2[i];
    }
    return b1;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:19,代码来源:TlsUtils.java

示例4: cloneHash

import org.bouncycastle.crypto.digests.MD5Digest; //导入依赖的package包/类
public static final Digest cloneHash(int hashAlgorithm, Digest hash)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return new MD5Digest((MD5Digest)hash);
    case HashAlgorithm.sha1:
        return new SHA1Digest((SHA1Digest)hash);
    case HashAlgorithm.sha224:
        return new SHA224Digest((SHA224Digest)hash);
    case HashAlgorithm.sha256:
        return new SHA256Digest((SHA256Digest)hash);
    case HashAlgorithm.sha384:
        return new SHA384Digest((SHA384Digest)hash);
    case HashAlgorithm.sha512:
        return new SHA512Digest((SHA512Digest)hash);
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:21,代码来源:TlsUtils.java

示例5: createHMACDigest

import org.bouncycastle.crypto.digests.MD5Digest; //导入依赖的package包/类
protected Digest createHMACDigest(int macAlgorithm)
    throws IOException
{
    switch (macAlgorithm)
    {
    case MACAlgorithm._null:
        return null;
    case MACAlgorithm.hmac_md5:
        return new MD5Digest();
    case MACAlgorithm.hmac_sha1:
        return new SHA1Digest();
    case MACAlgorithm.hmac_sha256:
        return new SHA256Digest();
    case MACAlgorithm.hmac_sha384:
        return new SHA384Digest();
    case MACAlgorithm.hmac_sha512:
        return new SHA512Digest();
    default:
        throw new TlsFatalAlert(AlertDescription.internal_error);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:22,代码来源:DefaultTlsCipherFactory.java

示例6: assign

import org.bouncycastle.crypto.digests.MD5Digest; //导入依赖的package包/类
public void assign(Object value, Assignable variable) {
	// Adds the security provider.
	logger.debug("Adding security provider.");
	Security.addProvider(new BouncyCastleProvider());

	logger.debug("Calculating MD5 Hash.");
	// Converts the input to a byte array.
	byte input[] = value.toString().getBytes();

	// Calculates the MD5 digest.
	MD5Digest md5 = new MD5Digest();
	md5.update(input, 0, input.length);

	// Gets the digest size and hashes it.
	byte[] digest = new byte[md5.getDigestSize()];
	md5.doFinal(digest, 0);

	String hash = new String(Hex.encode(digest));
	logger.debug("Setting Hash [{}] into variable [{}].", hash, variable);
	variable.set(hash);
}
 
开发者ID:aurasphere,项目名称:assignables,代码行数:22,代码来源:MD5AssignmentPolicy.java

示例7: PKCS12ParametersGenerator

import org.bouncycastle.crypto.digests.MD5Digest; //导入依赖的package包/类
/**
 * Construct a PKCS 12 Parameters generator. This constructor will
 * accept MD5, SHA1, and RIPEMD160.
 *
 * @param digest the digest to be used as the source of derived keys.
 * @exception IllegalArgumentException if an unknown digest is passed in.
 */
public PKCS12ParametersGenerator(
    Digest  digest)
{
    this.digest = digest;
    if (digest instanceof MD5Digest)
    {
        u = 128 / 8;
        v = 512 / 8;
    }
    else if (digest instanceof SHA1Digest)
    {
        u = 160 / 8;
        v = 512 / 8;
    }
    else if (digest instanceof RIPEMD160Digest)
    {
        u = 160 / 8;
        v = 512 / 8;
    }
    else
    {
        throw new IllegalArgumentException("Digest " + digest.getAlgorithmName() + " unsupported");
    }
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:32,代码来源:PKCS12ParametersGenerator.java

示例8: createHash

import org.bouncycastle.crypto.digests.MD5Digest; //导入依赖的package包/类
public static Digest createHash(short hashAlgorithm)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return new MD5Digest();
    case HashAlgorithm.sha1:
        return new SHA1Digest();
    case HashAlgorithm.sha224:
        return new SHA224Digest();
    case HashAlgorithm.sha256:
        return new SHA256Digest();
    case HashAlgorithm.sha384:
        return new SHA384Digest();
    case HashAlgorithm.sha512:
        return new SHA512Digest();
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:21,代码来源:TlsUtils.java

示例9: cloneHash

import org.bouncycastle.crypto.digests.MD5Digest; //导入依赖的package包/类
public static Digest cloneHash(short hashAlgorithm, Digest hash)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return new MD5Digest((MD5Digest)hash);
    case HashAlgorithm.sha1:
        return new SHA1Digest((SHA1Digest)hash);
    case HashAlgorithm.sha224:
        return new SHA224Digest((SHA224Digest)hash);
    case HashAlgorithm.sha256:
        return new SHA256Digest((SHA256Digest)hash);
    case HashAlgorithm.sha384:
        return new SHA384Digest((SHA384Digest)hash);
    case HashAlgorithm.sha512:
        return new SHA512Digest((SHA512Digest)hash);
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:21,代码来源:TlsUtils.java

示例10: createPasswordDigest

import org.bouncycastle.crypto.digests.MD5Digest; //导入依赖的package包/类
private static byte[] createPasswordDigest(
    ByteBuffer buffer, String password, Charset charset)
{
    Digest digest =
      (((buffer.get(ENCRYPTION_FLAGS_OFFSET) & USE_SHA1) != 0) ?
       new SHA1Digest() : new MD5Digest());

    byte[] passwordBytes = new byte[PASSWORD_LENGTH];

    if (password != null) {
      ByteBuffer bb = ColumnImpl.encodeUncompressedText(
          password.toUpperCase(), charset);
      bb.get(passwordBytes, 0,
             Math.min(passwordBytes.length, bb.remaining()));
    }

    // Get digest value
    byte[] digestBytes = hash(digest, passwordBytes, PASSWORD_DIGEST_LENGTH);
    return digestBytes;
}
 
开发者ID:jahlborn,项目名称:jackcessencrypt,代码行数:21,代码来源:MSISAMCryptCodecHandler.java

示例11: createHash

import org.bouncycastle.crypto.digests.MD5Digest; //导入依赖的package包/类
public static final Digest createHash(short hashAlgorithm)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return new MD5Digest();
    case HashAlgorithm.sha1:
        return new SHA1Digest();
    case HashAlgorithm.sha224:
        return new SHA224Digest();
    case HashAlgorithm.sha256:
        return new SHA256Digest();
    case HashAlgorithm.sha384:
        return new SHA384Digest();
    case HashAlgorithm.sha512:
        return new SHA512Digest();
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:21,代码来源:TlsUtils.java

示例12: cloneHash

import org.bouncycastle.crypto.digests.MD5Digest; //导入依赖的package包/类
public static final Digest cloneHash(short hashAlgorithm, Digest hash)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return new MD5Digest((MD5Digest)hash);
    case HashAlgorithm.sha1:
        return new SHA1Digest((SHA1Digest)hash);
    case HashAlgorithm.sha224:
        return new SHA224Digest((SHA224Digest)hash);
    case HashAlgorithm.sha256:
        return new SHA256Digest((SHA256Digest)hash);
    case HashAlgorithm.sha384:
        return new SHA384Digest((SHA384Digest)hash);
    case HashAlgorithm.sha512:
        return new SHA512Digest((SHA512Digest)hash);
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:21,代码来源:TlsUtils.java

示例13: createHMACDigest

import org.bouncycastle.crypto.digests.MD5Digest; //导入依赖的package包/类
protected Digest createHMACDigest(int macAlgorithm) throws IOException
{
    switch (macAlgorithm)
    {
    case MACAlgorithm._null:
        return null;
    case MACAlgorithm.hmac_md5:
        return new MD5Digest();
    case MACAlgorithm.hmac_sha1:
        return new SHA1Digest();
    case MACAlgorithm.hmac_sha256:
        return new SHA256Digest();
    case MACAlgorithm.hmac_sha384:
        return new SHA384Digest();
    case MACAlgorithm.hmac_sha512:
        return new SHA512Digest();
    default:
        throw new TlsFatalAlert(AlertDescription.internal_error);
    }
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:21,代码来源:DefaultTlsCipherFactory.java

示例14: PRF

import org.bouncycastle.crypto.digests.MD5Digest; //导入依赖的package包/类
protected static byte[] PRF(byte[] secret, String asciiLabel, byte[] seed, int size)
{
    byte[] label = Strings.toByteArray(asciiLabel);

    int s_half = (secret.length + 1) / 2;
    byte[] s1 = new byte[s_half];
    byte[] s2 = new byte[s_half];
    System.arraycopy(secret, 0, s1, 0, s_half);
    System.arraycopy(secret, secret.length - s_half, s2, 0, s_half);

    byte[] ls = concat(label, seed);

    byte[] buf = new byte[size];
    byte[] prf = new byte[size];
    hmac_hash(new MD5Digest(), s1, ls, prf);
    hmac_hash(new SHA1Digest(), s2, ls, buf);
    for (int i = 0; i < size; i++)
    {
        buf[i] ^= prf[i];
    }
    return buf;
}
 
开发者ID:coova,项目名称:jradius,代码行数:23,代码来源:TlsUtils.java

示例15: calculateKeyBlock_SSL

import org.bouncycastle.crypto.digests.MD5Digest; //导入依赖的package包/类
static byte[] calculateKeyBlock_SSL(byte[] master_secret, byte[] random, int size)
{
    Digest md5 = new MD5Digest();
    Digest sha1 = new SHA1Digest();
    int md5Size = md5.getDigestSize();
    byte[] shatmp = new byte[sha1.getDigestSize()];
    byte[] tmp = new byte[size + md5Size];

    int i = 0, pos = 0;
    while (pos < size)
    {
        byte[] ssl3Const = SSL3_CONST[i];

        sha1.update(ssl3Const, 0, ssl3Const.length);
        sha1.update(master_secret, 0, master_secret.length);
        sha1.update(random, 0, random.length);
        sha1.doFinal(shatmp, 0);

        md5.update(master_secret, 0, master_secret.length);
        md5.update(shatmp, 0, shatmp.length);
        md5.doFinal(tmp, pos);

        pos += md5Size;
        ++i;
    }

    byte rval[] = new byte[size];
    System.arraycopy(tmp, 0, rval, 0, size);
    return rval;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:31,代码来源:TlsUtils.java


注:本文中的org.bouncycastle.crypto.digests.MD5Digest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。