Examples of SecureRandom


Examples of java.security.SecureRandom

            {
                byte[]  iv = new byte[8];

                if (random == null)
                {
                    random = new SecureRandom();
                }

                random.nextBytes(iv);

                try
View Full Code Here

Examples of java.security.SecureRandom

        {
            byte[]  iv = new byte[16];

      if (random == null)
      {
                random = new SecureRandom();
      }

            random.nextBytes(iv);

            AlgorithmParameters params;
View Full Code Here

Examples of java.security.SecureRandom

        {
            byte[]  iv = new byte[8];

      if (random == null)
      {
                random = new SecureRandom();
      }

            random.nextBytes(iv);

            AlgorithmParameters params;
View Full Code Here

Examples of java.security.SecureRandom

        {
            byte[]  iv = new byte[8];

      if (random == null)
      {
                random = new SecureRandom();
      }

            random.nextBytes(iv);

            AlgorithmParameters params;
View Full Code Here

Examples of java.security.SecureRandom

     */
    public UID() {
 
  synchronized (lock) {
      if (!hostUniqueSet) {
    hostUnique = (new SecureRandom()).nextInt();
    hostUniqueSet = true;
      }
      unique = hostUnique;
      if (lastCount == Short.MAX_VALUE) {
    boolean interrupted = Thread.interrupted();
View Full Code Here

Examples of java.security.SecureRandom

import javax.crypto.spec.DESKeySpec;

public class DESFactory {

  public DESFactory(byte encKey[], byte desKey[]) throws Exception {
    SecureRandom sr = new SecureRandom();
    byte rawKeyData[] = encKey;
    DESKeySpec dks = new DESKeySpec(rawKeyData);
    SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
    javax.crypto.SecretKey key = keyFactory.generateSecret(dks);
    enCipher = Cipher.getInstance("DES");
View Full Code Here

Examples of java.security.SecureRandom

  public DESDecrypt(byte desKey[]) {
    this.desKey = desKey;
  }

  public byte[] doDecrypt(byte encryptText[]) throws Exception {
    SecureRandom sr = new SecureRandom();
    byte rawKeyData[] = desKey;
    DESKeySpec dks = new DESKeySpec(rawKeyData);
    SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
    javax.crypto.SecretKey key = keyFactory.generateSecret(dks);
    Cipher cipher = Cipher.getInstance("DES");
View Full Code Here

Examples of java.security.SecureRandom

  public DESEncrypt(byte desKey[]) {
    this.desKey = desKey;
  }

  public byte[] doEncrypt(byte plainText[]) throws Exception {
    SecureRandom sr = new SecureRandom();
    byte rawKeyData[] = desKey;
    DESKeySpec dks = new DESKeySpec(rawKeyData);
    SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
    javax.crypto.SecretKey key = keyFactory.generateSecret(dks);
    Cipher cipher = Cipher.getInstance("DES");
View Full Code Here

Examples of java.security.SecureRandom

  }

  public SymmetricEncryptHelper(byte[] key, String algorithm) {
    this.algorithm = algorithm;
    // DES算法要求有一个可信任的随机数源
    SecureRandom sr = new SecureRandom();
    try {
      // 从原始密匙数据创建DESKeySpec对象
      DESKeySpec dks = new DESKeySpec(key);
      // 创建一个密匙工厂,然后用它把DESKeySpec转换成
      // 一个SecretKey对象
View Full Code Here

Examples of java.security.SecureRandom

    BigInteger e = new BigInteger("15");
    BigInteger phi;

    byte[] nonce = new byte[(nbBits / 16) + 1];

    SecureRandom rand;
    try {
      rand = SecureRandom.getInstance("SHA1PRNG");
      rand.nextBytes(nonce);
    } catch (Exception ex) {
      System.err.println("Can't happen...");
      ex.printStackTrace();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.