• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java IMessageDigest类的典型用法和代码示例

java 2次浏览

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

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

示例1: getPSSSignature

点赞 3

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
private static final ISignature getPSSSignature(String name)
{
  name = name.substring(Registry.RSA_PSS_ENCODING.length()).trim();
  // remove the hyphen if found at the beginning
  if (name.startsWith("-"))
    name = name.substring(1).trim();

  IMessageDigest md;
  if (name.length() == 0)
    md = HashFactory.getInstance(Registry.SHA160_HASH);
  else
    {
      // check if there is such a hash
      md = HashFactory.getInstance(name);
      if (md == null)
        return null;
    }

  ISignature result = new RSAPSSSignature(md, 0);
  return result;
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:22,
代码来源:RSASignatureFactory.java

示例2: getPKCS1Signature

点赞 3

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
private static final ISignature getPKCS1Signature(String name)
{
  name = name.substring(Registry.RSA_PKCS1_V1_5_ENCODING.length()).trim();
  // remove the hyphen if found at the beginning
  if (name.startsWith("-"))
    name = name.substring(1).trim();

  IMessageDigest md;
  if (name.length() == 0)
    md = HashFactory.getInstance(Registry.SHA160_HASH);
  else
    {
      // check if there is such a hash
      md = HashFactory.getInstance(name);
      if (md == null)
        return null;
    }

  ISignature result = new RSAPKCS1V1_5Signature(md);
  return result;
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:22,
代码来源:RSASignatureFactory.java

示例3: EMSA_PKCS1_V1_5

点赞 3

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
/**
 * Trivial private constructor to enforce use through Factory method.
 *
 * @param hash the message digest instance to use with this scheme instance.
 */
private EMSA_PKCS1_V1_5(final IMessageDigest hash)
{
  super();

  this.hash = hash;
  hLen = hash.hashSize();
  final String name = hash.name();
  if (name.equals(Registry.MD2_HASH))
    prefix = MD2_PREFIX;
  else if (name.equals(Registry.MD5_HASH))
    prefix = MD5_PREFIX;
  else if (name.equals(Registry.SHA160_HASH))
    prefix = SHA160_PREFIX;
  else if (name.equals(Registry.SHA256_HASH))
    prefix = SHA256_PREFIX;
  else if (name.equals(Registry.SHA384_HASH))
    prefix = SHA384_PREFIX;
  else if (name.equals(Registry.SHA512_HASH))
    prefix = SHA512_PREFIX;
  else
    throw new UnsupportedOperationException(); // should not happen
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:28,
代码来源:EMSA_PKCS1_V1_5.java

示例4: instance

点赞 3

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
/**
 * Returns an instance of this object that uses the designated message digest
 * algorithm as its digest function.
 *
 * @return an instance of this object for the designated digest name.
 */
public static synchronized SRP instance(String mdName)
{
  if (mdName != null)
    mdName = mdName.trim().toLowerCase();
  if (mdName == null || mdName.equals(""))
    mdName = SRPRegistry.SRP_DEFAULT_DIGEST_NAME;
  SRP result = (SRP) algorithms.get(mdName);
  if (result == null)
    {
      final IMessageDigest mda = HashFactory.getInstance(mdName);
      result = new SRP(mda);
      algorithms.put(mdName, result);
    }
  return result;
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:22,
代码来源:SRP.java

示例5: generateM1

点赞 3

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
public byte[] generateM1(final BigInteger N, final BigInteger g,
                         final String U, final byte[] s, final BigInteger A,
                         final BigInteger B, final byte[] K, final String I,
                         final String L, final byte[] cn, final byte[] cCB)
    throws UnsupportedEncodingException
{
  final IMessageDigest hash = (IMessageDigest) mda.clone();
  byte[] b;
  b = xor(digest(Util.trim(N)), digest(Util.trim(g)));
  hash.update(b, 0, b.length);
  b = digest(U);
  hash.update(b, 0, b.length);
  hash.update(s, 0, s.length);
  b = Util.trim(A);
  hash.update(b, 0, b.length);
  b = Util.trim(B);
  hash.update(b, 0, b.length);
  hash.update(K, 0, K.length);
  b = digest(I);
  hash.update(b, 0, b.length);
  b = digest(L);
  hash.update(b, 0, b.length);
  hash.update(cn, 0, cn.length);
  hash.update(cCB, 0, cCB.length);
  return hash.digest();
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:27,
代码来源:SRP.java

示例6: Generator

点赞 3

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
public Generator(final IBlockCipher cipher, final IMessageDigest hash)
{
  super(Registry.FORTUNA_GENERATOR_PRNG);
  this.cipher = cipher;
  this.hash = hash;
  counter = new byte[cipher.defaultBlockSize()];
  buffer = new byte[cipher.defaultBlockSize()];
  int keysize = 0;
  for (Iterator it = cipher.keySizes(); it.hasNext();)
    {
      int ks = ((Integer) it.next()).intValue();
      if (ks > keysize)
        keysize = ks;
      if (keysize >= 32)
        break;
    }
  key = new byte[keysize];
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:19,
代码来源:Fortuna.java

示例7: instance

点赞 3

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
/**
 * Returns an instance of this object that uses the designated message digest
 * algorithm as its digest function.
 * 
 * @return an instance of this object for the designated digest name.
 */
public static synchronized SRP instance(String mdName)
{
  if (mdName != null)
    mdName = mdName.trim().toLowerCase();
  if (mdName == null || mdName.equals(""))
    mdName = SRPRegistry.SRP_DEFAULT_DIGEST_NAME;
  SRP result = (SRP) algorithms.get(mdName);
  if (result == null)
    {
      final IMessageDigest mda = HashFactory.getInstance(mdName);
      result = new SRP(mda);
      algorithms.put(mdName, result);
    }
  return result;
}
 

开发者ID:nmldiegues,
项目名称:jvm-stm,
代码行数:22,
代码来源:SRP.java

示例8: digest

点赞 2

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
private String digest(IMessageDigest hash, byte[] encoded)
{
  hash.update(encoded);
  byte[] b = hash.digest();
  StringBuilder sb = new StringBuilder().append(Util.toString(b, 0, 1));
  for (int i = 1; i < b.length; i++)
    sb.append(":").append(Util.toString(b, i, 1)); //$NON-NLS-1$

  String result = sb.toString();
  return result;
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:12,
代码来源:Command.java

示例9: RSAPKCS1V1_5Signature

点赞 2

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
/** Private constructor for cloning purposes. */
private RSAPKCS1V1_5Signature(final RSAPKCS1V1_5Signature that)
{
  this(that.md.name());

  this.publicKey = that.publicKey;
  this.privateKey = that.privateKey;
  this.md = (IMessageDigest) that.md.clone();
  this.pkcs1 = (EMSA_PKCS1_V1_5) that.pkcs1.clone();
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:11,
代码来源:RSAPKCS1V1_5Signature.java

示例10: getInstance

点赞 2

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
/**
 * Returns an instance of this object given a designated name of a hash
 * function.
 *
 * @param mdName the canonical name of a hash function.
 * @return an instance of this object configured for use with the designated
 * options.
 * @throws UnsupportedOperationException if the hash function is not
 * implemented or does not have an ID listed in RFC-3447.
 */
public static final EMSA_PKCS1_V1_5 getInstance(final String mdName)
{
  final IMessageDigest hash = HashFactory.getInstance(mdName);
  final String name = hash.name();
  if (! (name.equals(Registry.MD2_HASH)
        || name.equals(Registry.MD5_HASH)
        || name.equals(Registry.SHA160_HASH)
        || name.equals(Registry.SHA256_HASH)
        || name.equals(Registry.SHA384_HASH)
        || name.equals(Registry.SHA512_HASH)))
    throw new UnsupportedOperationException("hash with no OID: " + name);

  return new EMSA_PKCS1_V1_5(hash);
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:25,
代码来源:EMSA_PKCS1_V1_5.java

示例11: EMSA_PSS

点赞 2

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
/**
 * Trivial private constructor to enforce use through Factory method.
 *
 * @param hash the message digest instance to use with this scheme instance.
 */
private EMSA_PSS(IMessageDigest hash)
{
  super();

  this.hash = hash;
  hLen = hash.hashSize();
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:13,
代码来源:EMSA_PSS.java

示例12: RSAPSSSignature

点赞 2

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
public RSAPSSSignature(IMessageDigest md, int sLen)
{
  super(Registry.RSA_PSS_SIG, md);

  pss = EMSA_PSS.getInstance(md.name());
  this.sLen = sLen;
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:8,
代码来源:RSAPSSSignature.java

示例13: BaseSignature

点赞 2

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
/**
 * Trivial constructor.
 *
 * @param schemeName the name of this signature scheme.
 * @param md the underlying instance of the message digest algorithm.
 * @throws IllegalArgumentException if the designated hash instance is
 *           <code>null</code>.
 */
protected BaseSignature(String schemeName, IMessageDigest md)
{
  super();

  this.schemeName = schemeName;
  if (md == null)
    throw new IllegalArgumentException("Message digest MUST NOT be null");

  this.md = md;
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:19,
代码来源:BaseSignature.java

示例14: DSSSignature

点赞 2

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
/** Private constructor for cloning purposes. */
private DSSSignature(DSSSignature that)
{
  this();

  this.publicKey = that.publicKey;
  this.privateKey = that.privateKey;
  this.md = (IMessageDigest) that.md.clone();
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:10,
代码来源:DSSSignature.java

示例15: clone

点赞 2

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
public Object clone() throws CloneNotSupportedException
{
  MDGenerator result = (MDGenerator) super.clone();
  if (this.md != null)
    result.md = (IMessageDigest) this.md.clone();

  return result;
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:9,
代码来源:MDGenerator.java

示例16: MessageDigestAdapter

点赞 2

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
/**
 * Private constructor for cloning purposes.
 *
 * @param adaptee a clone of the underlying hash algorithm instance.
 */
private MessageDigestAdapter(IMessageDigest adaptee)
{
  super();

  this.adaptee = adaptee;
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:12,
代码来源:MessageDigestAdapter.java

示例17: SRP

点赞 2

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
/** Trivial private constructor to enforce Singleton pattern. */
private SRP(final IMessageDigest mda)
{
  super();

  this.mda = mda;
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:8,
代码来源:SRP.java

示例18: generateM2

点赞 2

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
public byte[] generateM2(final BigInteger A, final byte[] M1, final byte[] K,
                         final String U, final String I, final String o,
                         final byte[] sid, final int ttl, final byte[] cIV,
                         final byte[] sIV, final byte[] sCB)
    throws UnsupportedEncodingException
{
  final IMessageDigest hash = (IMessageDigest) mda.clone();
  byte[] b;
  b = Util.trim(A);
  hash.update(b, 0, b.length);
  hash.update(M1, 0, M1.length);
  hash.update(K, 0, K.length);
  b = digest(U);
  hash.update(b, 0, b.length);
  b = digest(I);
  hash.update(b, 0, b.length);
  b = digest(o);
  hash.update(b, 0, b.length);
  hash.update(sid, 0, sid.length);
  hash.update((byte)(ttl >>> 24));
  hash.update((byte)(ttl >>> 16));
  hash.update((byte)(ttl >>> 8));
  hash.update((byte) ttl);
  hash.update(cIV, 0, cIV.length);
  hash.update(sIV, 0, sIV.length);
  hash.update(sCB, 0, sCB.length);
  return hash.digest();
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:29,
代码来源:SRP.java

示例19: generateKn

点赞 2

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
public byte[] generateKn(final byte[] K, final byte[] cn, final byte[] sn)
{
  final IMessageDigest hash = (IMessageDigest) mda.clone();
  hash.update(K, 0, K.length);
  hash.update(cn, 0, cn.length);
  hash.update(sn, 0, sn.length);
  return hash.digest();
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:9,
代码来源:SRP.java

示例20: computeX

点赞 2

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
private byte[] computeX(final byte[] s, final byte[] user, final byte[] p)
{
  final IMessageDigest hash = (IMessageDigest) mda.clone();
  hash.update(user, 0, user.length);
  hash.update(COLON);
  hash.update(p, 0, p.length);
  final byte[] up = hash.digest();
  hash.update(s, 0, s.length);
  hash.update(up, 0, up.length);
  return hash.digest();
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:12,
代码来源:SRP.java

示例21: Fortuna

点赞 2

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
public Fortuna()
{
  super(Registry.FORTUNA_PRNG);
  generator = new Generator(CipherFactory.getInstance(Registry.RIJNDAEL_CIPHER),
                            HashFactory.getInstance(Registry.SHA256_HASH));
  pools = new IMessageDigest[NUM_POOLS];
  for (int i = 0; i < NUM_POOLS; i++)
    pools[i] = HashFactory.getInstance(Registry.SHA256_HASH);
  lastReseed = 0;
  pool = 0;
  pool0Count = 0;
  buffer = new byte[256];
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:14,
代码来源:Fortuna.java

示例22: HMac

点赞 2

import gnu.java.security.hash.IMessageDigest; //导入依赖的package包/类
/**
 * Trivial constructor for use by concrete subclasses.
 *
 * @param underlyingHash the underlying hash algorithm instance.
 */
protected HMac(IMessageDigest underlyingHash)
{
  super(Registry.HMAC_NAME_PREFIX + underlyingHash.name(), underlyingHash);

  this.blockSize = underlyingHash.blockSize();
  this.macSize = underlyingHash.hashSize();
  ipadHash = opadHash = null;
}
 

开发者ID:vilie,
项目名称:javify,
代码行数:14,
代码来源:HMac.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)