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

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

java 2次浏览

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

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

示例1: engineGenerateSecret

点赞 2

import gnu.javax.crypto.prng.PRNGFactory; //导入依赖的package包/类
protected SecretKey engineGenerateSecret(KeySpec spec)
    throws InvalidKeySpecException
{
  if (! (spec instanceof PBEKeySpec))
    throw new InvalidKeySpecException("not a PBEKeySpec");
  IRandom kdf = PRNGFactory.getInstance("PBKDF2-" + macName);
  HashMap attr = new HashMap();
  attr.put(IPBE.PASSWORD, ((PBEKeySpec) spec).getPassword());
  byte[] salt = ((PBEKeySpec) spec).getSalt();
  if (salt == null)
    salt = new byte[0];
  attr.put(IPBE.SALT, salt);
  int ic = ((PBEKeySpec) spec).getIterationCount();
  if (ic <= 0)
    ic = DEFAULT_ITERATION_COUNT;
  attr.put(IPBE.ITERATION_COUNT, Integer.valueOf(ic));
  kdf.init(attr);
  int len = ((PBEKeySpec) spec).getKeyLength();
  if (len <= 0)
    len = DEFAULT_KEY_LEN;
  byte[] dk = new byte[len];
  try
    {
      kdf.nextBytes(dk, 0, len);
    }
  catch (LimitReachedException lre)
    {
      throw new IllegalArgumentException(lre.toString());
    }
  return new SecretKeySpec(dk, "PBKDF2");
}
 

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

示例2: genkey

点赞 2

import gnu.javax.crypto.prng.PRNGFactory; //导入依赖的package包/类
private SecretKeySpec genkey(PBEKey key) throws InvalidKeyException
{
  IRandom kdf = PRNGFactory.getInstance("PBKDF2-" + macName);
  if (kdf == null)
    throw new IllegalArgumentException("no such KDF: PBKDF2-" + macName);
  HashMap attrib = new HashMap();
  attrib.put(IPBE.ITERATION_COUNT, Integer.valueOf(key.getIterationCount()));
  attrib.put(IPBE.PASSWORD, key.getPassword());
  attrib.put(IPBE.SALT, key.getSalt());
  try
    {
      kdf.init(attrib);
    }
  catch (IllegalArgumentException iae)
    {
      throw new InvalidKeyException(iae.toString());
    }
  byte[] dk = new byte[mode.defaultKeySize()];
  try
    {
      kdf.nextBytes(dk, 0, dk.length);
    }
  catch (LimitReachedException shouldNotHappen)
    {
      throw new Error(String.valueOf(shouldNotHappen));
    }
  return new SecretKeySpec(dk, cipher.name());
}
 

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

示例3: ARCFourRandomSpi

点赞 2

import gnu.javax.crypto.prng.PRNGFactory; //导入依赖的package包/类
/**
 * Default 0-arguments constructor.
 */
public ARCFourRandomSpi()
{
  super();
  adaptee = PRNGFactory.getInstance(Registry.ARCFOUR_PRNG);
  virgin = true;
}
 

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

示例4: ARCFourSpi

点赞 2

import gnu.javax.crypto.prng.PRNGFactory; //导入依赖的package包/类
public ARCFourSpi()
{
  super();
  keystream = PRNGFactory.getInstance(Registry.ARCFOUR_PRNG);
}
 

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


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