类 UAes
java.lang.Object
com.gdxsoft.easyweb.utils.UAes
- 所有已实现的接口:
IUSymmetricEncyrpt
AES Encrypt / Decrypt Utils GCM/CCM/CBC/ECB/CFB/OFB/CTR 128, 192, 256
-
字段概要
字段修饰符和类型字段说明static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidcreateKey(byte[] keyBytes) Initialize the password and iv
iv = Reverse keyBytes已过时。decrypt(byte[] encryptedData) Decrypt the encrypted dataDecrypt the base64 encoded ciphertextDecrypt the base64 encoded ciphertextbyte[]decryptBytes(byte[] encryptedData) Decrypt datastatic StringdefaultDecrypt(String base64Ciphertext) Default decryptstatic StringdefaultEncrypt(String plainText) Default encrypt已过时。Encrypt StringEncrypt String with charsetNamebyte[]encryptBytes(byte[] plainData) Encrypt datastatic byte[]generateRandomBytes(int Length) Generate a random buffContinues a multi-part update of the Additional AuthenticationData (AAD).Block cipher mode of operation, the default is CBCGet then cipher namebyte[]getDesBytes(byte[] bytesEncrypt) 已过时。getDesString(byte[] byteMi) 已过时。getDesString(String strMi) 已过时。byte[]getEncBytes(String strMing) 已过时。getEncString(String strMing) 已过时。static UAesGet a AES with default key and ivintAES key bytes length (16:128, 24:192, 32:256)intGet the GCM/CCM mac bits size, default is 128PADDING AES/CBC/PKCS7Paddingstatic voidinitDefaultKey(String key, String iv) Initialize the default key and iv, the algorithm is AES_128_GCMstatic voidinitDefaultKey(String algorithm, String key, String iv) Initialize the default algorithm and key and ivstatic voidinitDefaultKey(String algorithm, String key, String iv, int macSize) Initialize the default algorithm and key and iv and macSizestatic voidinitDefaultKey(String algorithm, String key, String iv, int macSize, String aad) Initialize the default algorithm and key and iv and macSize and aadbooleanisAutoIv()booleanwhether to use the BouncyCastle provider, default is BouncyCastlevoidsetAdditionalAuthenticationData(String additionalAuthenticationData) Continues a multi-part update of the Additional AuthenticationData (AAD).voidsetAutoIv(boolean autoIv) voidsetCipherName(String cipherName) Set the cipher namevoidsetMacSizeBits(int macSizeBits) Set the GCM/CCM mac bits size, default is 128voidsetPaddingMethod(String paddingMethod) PADDING AES/CBC/PKCS7PaddingvoidsetUsingBc(boolean usingBc) Set whether to use the BouncyCastle provider
-
字段详细资料
-
AES_128_GCM
- 另请参阅:
-
AES_192_GCM
- 另请参阅:
-
AES_256_GCM
- 另请参阅:
-
AES_128_CCM
- 另请参阅:
-
AES_192_CCM
- 另请参阅:
-
AES_256_CCM
- 另请参阅:
-
AES_128_CBC
- 另请参阅:
-
AES_192_CBC
- 另请参阅:
-
AES_256_CBC
- 另请参阅:
-
AES_128_CFB
- 另请参阅:
-
AES_192_CFB
- 另请参阅:
-
AES_256_CFB
- 另请参阅:
-
AES_128_CTR
- 另请参阅:
-
AES_192_CTR
- 另请参阅:
-
AES_256_CTR
- 另请参阅:
-
AES_128_OFB
- 另请参阅:
-
AES_192_OFB
- 另请参阅:
-
AES_256_OFB
- 另请参阅:
-
AES_128_ECB
- 另请参阅:
-
AES_192_ECB
- 另请参阅:
-
AES_256_ECB
- 另请参阅:
-
PKCS7Padding
- 另请参阅:
-
PKCS5Padding
- 另请参阅:
-
NoPadding
- 另请参阅:
-
-
构造器详细资料
-
UAes
public UAes()Initialize AES (AES_128_CBC) -
UAes
Initialize AES (AES_128_CBC)- 参数:
key- keyiv- iv
-
UAes
Initialize AES- 参数:
key- the passwordiv- the ivcipherName- the cipher name (aes-128-gcm ...)
-
UAes
public UAes(byte[] keyBuf, byte[] ivBuf) Initialize AES (AES_128_CBC)- 参数:
keyBuf- the password bytesivBuf- the iv bytes
-
UAes
Initialize AES- 参数:
keyBuf- the password bytesivBuf- the iv bytescipherName- the cipher name (aes-128-gcm ...)
-
-
方法详细资料
-
initDefaultKey
Initialize the default key and iv, the algorithm is AES_128_GCM- 参数:
key- the keyiv- the iv
-
initDefaultKey
Initialize the default algorithm and key and iv- 参数:
algorithm- the AES algorithmkey- the keyiv- the iv
-
initDefaultKey
Initialize the default algorithm and key and iv and macSize- 参数:
algorithm- the AES algorithm (GCM/CCM)key- the keyiv- the ivmacSize- the GCM/CCM macBitSize
-
initDefaultKey
Initialize the default algorithm and key and iv and macSize and aad- 参数:
algorithm- the AES algorithm (GCM/CCM)key- the keyiv- the ivmacSize- the GCM/CCM macBitSizeaad- the GCM/CCM Additional AuthenticationData
-
getInstance
Get a AES with default key and iv- 返回:
- AES
- 抛出:
Exception
-
defaultEncrypt
Default encrypt- 参数:
plainText- plain text- 返回:
- Encrypted base64
- 抛出:
Exception
-
defaultDecrypt
Default decrypt- 参数:
base64Ciphertext- Encrypted base64- 返回:
- Plain text
- 抛出:
Exception
-
encryptBytes
Encrypt data- 指定者:
encryptBytes在接口中IUSymmetricEncyrpt- 参数:
plainData- data- 返回:
- encrypted data
- 抛出:
Exception
-
decryptBytes
Decrypt data- 指定者:
decryptBytes在接口中IUSymmetricEncyrpt- 参数:
encryptedData- the encrypted data- 返回:
- plain data
- 抛出:
Exception
-
getBlockCipherMode
Block cipher mode of operation, the default is CBC- 返回:
- CBC/CFB/ECB ...
-
generateRandomBytes
public static byte[] generateRandomBytes(int Length) Generate a random buff- 参数:
Length- the buff length- 返回:
- the random buff
-
encrypt
Encrypt String with charsetName- 指定者:
encrypt在接口中IUSymmetricEncyrpt- 参数:
source- the source stringcharsetName- the charsetNamee UTF8/GBK ...- 返回:
- the base64 encoded ciphertext
- 抛出:
Exception
-
encrypt
Encrypt String- 指定者:
encrypt在接口中IUSymmetricEncyrpt- 参数:
source- the UTF8 string- 返回:
- the base64 encoded ciphertext
- 抛出:
Exception
-
encode
已过时。Encrypt String, same as encrypt- 抛出:
Exception
-
getEncString
已过时。Encrypt String, same as encrypt- 抛出:
Exception
-
decrypt
Decrypt the base64 encoded ciphertext- 指定者:
decrypt在接口中IUSymmetricEncyrpt- 参数:
base64Ciphertext- the base64 encoded ciphertextcharsetName- the return text's character set- 返回:
- the plain text
- 抛出:
Exception
-
decrypt
Decrypt the base64 encoded ciphertext- 指定者:
decrypt在接口中IUSymmetricEncyrpt- 参数:
base64Ciphertext- the base64 encoded ciphertext- 返回:
- the plain text (UTF8)
- 抛出:
Exception
-
decrypt
Decrypt the encrypted data- 参数:
encryptedData- the encrypted data- 返回:
- the plain text (UTF8)
- 抛出:
Exception
-
getKeyLength
public int getKeyLength()AES key bytes length (16:128, 24:192, 32:256)- 返回:
- the key's length
-
getDesString
已过时。Decrypt- 抛出:
Exception
-
decode
已过时。Decrypt- 抛出:
Exception
-
getEncBytes
已过时。Encrypt- 抛出:
Exception
-
getDesString
已过时。Decrypt- 抛出:
Exception
-
getDesBytes
已过时。DecryptBytes- 抛出:
Exception
-
createKey
public void createKey(byte[] keyBytes) Initialize the password and iv
iv = Reverse keyBytes- 参数:
keyBytes- the password
-
getPaddingMethod
PADDING AES/CBC/PKCS7Padding- 返回:
- PADDING
-
setPaddingMethod
PADDING AES/CBC/PKCS7Padding- 参数:
paddingMethod- PADDING
-
getCipherName
Get then cipher name- 返回:
- the cipherName
-
setCipherName
Set the cipher name- 参数:
cipherName- the cipher name
-
getMacSizeBits
public int getMacSizeBits()Get the GCM/CCM mac bits size, default is 128- 返回:
- the GCM/CCM mac bits size
-
setMacSizeBits
public void setMacSizeBits(int macSizeBits) Set the GCM/CCM mac bits size, default is 128- 参数:
macSizeBits- 32 ~ 128 , divisible by 8
-
isUsingBc
public boolean isUsingBc()whether to use the BouncyCastle provider, default is BouncyCastle- 返回:
- whether to use the BouncyCastle
-
setUsingBc
public void setUsingBc(boolean usingBc) Set whether to use the BouncyCastle provider- 参数:
usingBc- true=BC,false=java.security
-
getAdditionalAuthenticationData
Continues a multi-part update of the Additional AuthenticationData (AAD). Calls to this method provide AAD to the cipher when operating inmodes such as AEAD (GCM/CCM).- 返回:
- the AAD
-
setAdditionalAuthenticationData
Continues a multi-part update of the Additional AuthenticationData (AAD). Calls to this method provide AAD to the cipher when operating inmodes such as AEAD (GCM/CCM).- 参数:
additionalAuthenticationData- AAD
-
isAutoIv
public boolean isAutoIv() -
setAutoIv
public void setAutoIv(boolean autoIv) -
getMapCiphers
-