获取指定keysize的AES密钥,通过AESUtils类的静态常量指定

@return 返回密钥的字节数组, 失败返回null
773528
public static byte[] getKey(Integer length) {
        if (!AESUtil.SHORT.equals(length) && !AESUtil.MIDDLE.equals(length) && !AESUtil.LONG.equals(length)) {
            throw new RuntimeException("指定的KeySize不正确");
        }
        SecretKey key = null;
        try {
            KeyGenerator keyGen = KeyGenerator.getInstance("AES");
            keyGen.init(length);
            key = keyGen.generateKey();
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
        return key.getEncoded();
    }
62705
public int size() {
		writeLock.lock();
		try {
			if (this.size < 0) {
				this.size = 0;
				for (LinkedHashMap<String, String> value : this.values()) {
					this.size += value.size();
				}
			}
		} finally {
			writeLock.unlock();
		}
		return this.size;
	}
1054317
private static byte[] generateKey(int size) throws SymmetricKeyException {
        if (size <= 0)
            throw new IllegalArgumentException("Size cannot be zero or less than zero.");

        try {
            SecureRandom secureRandom = new SecureRandom();
            KeyGenerator keyGenerator = KeyGenerator.getInstance("AES");
            keyGenerator.init(size * 8, secureRandom);
            return keyGenerator.generateKey().getEncoded();
        } catch (NoSuchAlgorithmException e) {
            throw new SymmetricKeyException(e);
        }
    }
1189365
@Override
    public int size () {
        return 4 + ( this.hashAlgos != null ? 2 * this.hashAlgos.length : 0 ) + ( this.salt != null ? this.salt.length : 0 );
    }
772978
private static byte[] withCorrectBlockSize(final byte[] key) {
        if (key.length != CcAes.BLOCK) {
            throw new IllegalArgumentException(
                String.format(
                    "the length of the AES key must be exactly %d bytes",
                    CcAes.BLOCK
                )
            );
        }
        return key;
    }
1192803
public Symm obtain(byte[] key) throws IOException {
	  try {
		byte[] bytes = new byte[AES.AES_KEY_SIZE/8];
		int offset = (Math.abs(key[(47%key.length)])+137)%(key.length-bytes.length);
		for(int i=0;i<bytes.length;++i) {
			bytes[i] = key[i+offset];
		}

	  	aes = new AES(bytes,0,bytes.length);
	  } catch (Exception e) {
		  throw new IOException(e);
	  }
		int filled = codeset.length;
		char[] seq = new char[filled];
		int end = filled--;
		
		boolean right = true;
		int index;
		Obtain o = new Obtain(this,key);
		
		while(filled>=0) {
			index = o.next();
			if(index<0 || index>=codeset.length) {
				System.out.println("uh, oh");
			}
			if(right) { // alternate going left or right to find the next open slot (keeps it from taking too long to hit something) 
				for(int j=index;j<end;++j) {
					if(seq[j]==0) {
						seq[j]=codeset[filled];
						--filled;
						break;
					}
				}
				right = false;
			} else {
				for(int j=index;j>=0;--j) {
					if(seq[j]==0) {
						seq[j]=codeset[filled];
						--filled;
						break;
					}
				}
				right = true;
			}
		}
		return new Symm(seq,this);
	}
1208402
public function getKeySize() {
		switch ($this->algorithm) {
			case self::ALGORITHM_AES_128_CBC:
			case self::ALGORITHM_AES_128_CCM:
			case self::ALGORITHM_AES_128_CFB:
			case self::ALGORITHM_AES_128_CFB1:
			case self::ALGORITHM_AES_128_CFB8:
			case self::ALGORITHM_AES_128_CTR:
			case self::ALGORITHM_AES_128_ECB:
			case self::ALGORITHM_AES_128_GCM:
			case self::ALGORITHM_AES_128_OFB:
			case self::ALGORITHM_AES_128_XTS:
			case self::ALGORITHM_CAMELLIA_128_CBC:
			case self::ALGORITHM_CAMELLIA_128_CFB:
			case self::ALGORITHM_CAMELLIA_128_CFB1:
			case self::ALGORITHM_CAMELLIA_128_CFB8:
			case self::ALGORITHM_CAMELLIA_128_ECB:
			case self::ALGORITHM_CAMELLIA_128_OFB:
			case self::ALGORITHM_ID_AES128_CCM:
			case self::ALGORITHM_ID_AES128_GCM:
			case self::ALGORITHM_ID_AES128_WRAP:
			//@see: https://wiki.openssl.org/index.php/Manual:Enc(1)
			//->Blowfish and RC5 algorithms use a 128 bit key. 
			case self::ALGORITHM_BF_CBC:
			case self::ALGORITHM_BF_CFB:
			case self::ALGORITHM_BF_ECB:
			case self::ALGORITHM_BF_OFB:
			//@see http://www.gnu.org/software/gnu-crypto/manual/api/gnu/crypto/cipher/Cast5.html
			//-> since the CAST5 key schedule assumes an input key of 128 bits
			case self::ALGORITHM_CAST5_CBC:
			case self::ALGORITHM_CAST5_CFB:
			case self::ALGORITHM_CAST5_ECB:
			case self::ALGORITHM_CAST5_OFB:
			//@see https://en.wikipedia.org/wiki/International_Data_Encryption_Algorithm
			case self::ALGORITHM_IDEA_CBC:
			case self::ALGORITHM_IDEA_CFB:
			case self::ALGORITHM_IDEA_ECB:
			case self::ALGORITHM_IDEA_OFB:
			//@see https://wiki.openssl.org/index.php/Manual:Enc(1)
			case self::ALGORITHM_RC2_CBC:
			case self::ALGORITHM_RC2_CFB:
			case self::ALGORITHM_RC2_ECB:
			case self::ALGORITHM_RC2_OFB:
			case self::ALGORITHM_RC4:
			case self::ALGORITHM_SEED_CBC:
			case self::ALGORITHM_SEED_CFB:
			case self::ALGORITHM_SEED_ECB:
			case self::ALGORITHM_SEED_OFB:
				return 16;
				
			//@asee https://www.tutorialspoint.com/cryptography/triple_des.htm
			case self::ALGORITHM_DES_EDE:
			case self::ALGORITHM_DES_EDE_CBC:
			case self::ALGORITHM_DES_EDE_CFB:
			case self::ALGORITHM_DES_EDE_OFB:
				return 14;
			
			case self::ALGORITHM_AES_192_CBC:
			case self::ALGORITHM_AES_192_CCM:
			case self::ALGORITHM_AES_192_CFB:
			case self::ALGORITHM_AES_192_CFB1:
			case self::ALGORITHM_AES_192_CFB8:
			case self::ALGORITHM_AES_192_CTR:
			case self::ALGORITHM_AES_192_ECB:
			case self::ALGORITHM_AES_192_GCM:
			case self::ALGORITHM_AES_192_OFB:
			case self::ALGORITHM_CAMELLIA_192_CBC:
			case self::ALGORITHM_CAMELLIA_192_CFB:
			case self::ALGORITHM_CAMELLIA_192_CFB1:
			case self::ALGORITHM_CAMELLIA_192_CFB8:
			case self::ALGORITHM_CAMELLIA_192_ECB:
			case self::ALGORITHM_CAMELLIA_192_OFB:
			case self::ALGORITHM_ID_AES192_CCM:
			case self::ALGORITHM_ID_AES192_GCM:
			case self::ALGORITHM_ID_AES192_WRAP:
				return 24;
			
			//@asee https://www.tutorialspoint.com/cryptography/triple_des.htm
			case self::ALGORITHM_DES_EDE3:
			case self::ALGORITHM_DES_EDE3_CBC:
			case self::ALGORITHM_DES_EDE3_CFB:
			case self::ALGORITHM_DES_EDE3_CFB1:
			case self::ALGORITHM_DES_EDE3_CFB8:
			case self::ALGORITHM_DES_EDE3_OFB:
				return 21;
				
			
			case self::ALGORITHM_AES_256_CBC:
			case self::ALGORITHM_AES_256_CFB:
			case self::ALGORITHM_AES_256_CCM:
			case self::ALGORITHM_AES_256_CFB1:
			case self::ALGORITHM_AES_256_CFB8:
			case self::ALGORITHM_AES_256_CTR:
			case self::ALGORITHM_AES_256_ECB:
			case self::ALGORITHM_AES_256_GCM:
			case self::ALGORITHM_AES_256_OFB:
			case self::ALGORITHM_AES_256_XTS:
			case self::ALGORITHM_CAMELLIA_256_CBC:
			case self::ALGORITHM_CAMELLIA_256_CFB:
			case self::ALGORITHM_CAMELLIA_256_CFB1:
			case self::ALGORITHM_CAMELLIA_256_CFB8:
			case self::ALGORITHM_CAMELLIA_256_ECB:
			case self::ALGORITHM_CAMELLIA_256_OFB:
			case self::ALGORITHM_ID_AES256_CCM:
			case self::ALGORITHM_ID_AES256_GCM:
			case self::ALGORITHM_ID_AES256_WRAP:
				return 32;
			
			
			//@see https://en.wikipedia.org/wiki/Data_Encryption_Standard
			case self::ALGORITHM_DES_CBC:
			case self::ALGORITHM_DES_CFB:
			case self::ALGORITHM_DES_CFB1:
			case self::ALGORITHM_DES_CFB8:
			case self::ALGORITHM_DES_ECB:
			case self::ALGORITHM_DES_OFB:
			//@see https://en.wikipedia.org/wiki/des-X
			case self::ALGORITHM_DESX_CBC:
				return 7;
			

			case self::ALGORITHM_RC2_40_CBC:
 			case self::ALGORITHM_RC4_40:
				return 5;
				
 			case self::ALGORITHM_RC2_64_CBC:
 				return 8;
 			
			return 128;
		}
	}
8977
public IntegerSize getIntegerSize()
    {
        load_once();
        if (_value_type != IonType.INT || _v.isNull())
        {
            return null;
        }
        return _Private_ScalarConversions.getIntegerSize(_v.getAuthoritativeType());
    }
1016428
static public int getByteSize() {
    int size = 0;
    size += 16;
    size += 16;
    size += 24;
    size += 24;
    size += 20;
    size += 3;
    size += 5;
    size += 36;
    size += 64;
    size += 64;
    size = size/8;
    return size;
  }
772132
@Nullable
    public String getIdentityPublicKey() {
        RSAPublicKey key = InstanceIdentityProvider.RSA.getPublicKey();
        return key == null ? null : new String(Base64.encodeBase64(key.getEncoded()), Charset.forName("UTF-8"));
    }
753493
function getSizes(validReq) {
  const sizes = validReq.sizes;
  if (!sizes || sizes.length < 1) return null;
  let sizesStr = '';
  for (const i in sizes) {
    const size = sizes[i];
    if (size.length !== 2) return null;
    sizesStr += `${size[0]}x${size[1]},`;
  }
  if (sizesStr || sizesStr.lastIndexOf(',') === sizesStr.length - 1) {
    sizesStr = sizesStr.substring(0, sizesStr.length - 1);
  }
  return sizesStr;
}
1311925
private int getLength()
    {
        if (m_length_ >= 0) {
            return m_length_;
        }
        int length = m_key_.length;
        for (int index = 0; index < length; index ++) {
            if (m_key_[index] == 0) {
                length = index;
                break;
            }
        }
        m_length_ = length;
        return m_length_;
    }
1283249
public String getAccessKeyAsString() {
		char accessKey = getComponentModel().accessKey;

		if (Character.isLetterOrDigit(accessKey)) {
			return String.valueOf(accessKey);
		}

		return null;
	}
1096058
private int keyColumnEnd()
  {
    int offset = 0;
    
    for (int i = 0; i < _columns.length; i++) {
      if (offset == _keyStart + _keyLength) {
        return i;
      }
      
      offset += _columns[i].length();
    }
    
    if (offset == _keyStart + _keyLength) {
      return _columns.length;
    }
    
    throw new IllegalStateException();
  }
1081207
public static byte[] generateAesKey(final int keysize) {
		try {
			KeyGenerator keyGenerator = KeyGenerator.getInstance(AES_NAME);
			keyGenerator.init(keysize);
			SecretKey secretKey = keyGenerator.generateKey();
			return secretKey.getEncoded();
		} catch (NoSuchAlgorithmException e) {
			throw new ImpossibleException(e);
		}
	}
145958
protected byte[] getUpperBytesInternal() {
		byte cached[];
		if(hasNoValueCache()) {
			ValueCache cache = valueCache;
			cache.upperBytes = cached = getBytesImpl(false);
			if(!isMultiple()) {
				cache.lowerBytes = cached;
			}
		} else {
			ValueCache cache = valueCache;
			if((cached = cache.upperBytes) == null) {
				if(!isMultiple()) {
					if((cached = cache.lowerBytes) != null) {
						cache.upperBytes = cached;
					} else {
						cache.lowerBytes = cache.upperBytes = cached = getBytesImpl(false);
					}
				} else {
					cache.upperBytes = cached = getBytesImpl(false);
				}
			}
		}
		return cached;
	}
234445
public function getKeySize() {
        return mcrypt_get_key_size($this->supportedAlgos[$this->algo], $this->supportedModes[$this->mode]);
    }