public final class SecureAESTool
extends java.lang.Object
限定符和类型 | 方法和说明 |
---|---|
byte[] |
decrypt(javax.crypto.spec.SecretKeySpec key,
byte[] iv,
byte[] decodedCipherText)
More flexible AES decrypt that doesn't encode
|
java.lang.String |
decrypt(java.lang.String password,
java.lang.String base64EncodedCipherText)
Decrypt and decode ciphertext using 256-bit AES with key generated from password
|
byte[] |
encrypt(javax.crypto.spec.SecretKeySpec key,
byte[] iv,
byte[] message)
More flexible AES encrypt that doesn't encode
|
java.lang.String |
encrypt(java.lang.String password,
java.lang.String message)
Encrypt and encode message using 256-bit AES with key generated from password.
|
static SecureAESTool |
instance() |
public static SecureAESTool instance()
public java.lang.String encrypt(java.lang.String password, java.lang.String message) throws java.security.GeneralSecurityException
password
- used to generated keymessage
- the thing you want to encrypt assumed String UTF-8java.security.GeneralSecurityException
- if problems occur during encryptionpublic byte[] encrypt(javax.crypto.spec.SecretKeySpec key, byte[] iv, byte[] message) throws java.security.GeneralSecurityException
key
- AES key typically 128, 192 or 256 bitiv
- Initiation Vectormessage
- in bytes (assumed it's already been decoded)java.security.GeneralSecurityException
- if something goes wrong during encryptionpublic java.lang.String decrypt(java.lang.String password, java.lang.String base64EncodedCipherText) throws java.security.GeneralSecurityException
password
- used to generated keybase64EncodedCipherText
- the encrpyted message encoded with base64java.security.GeneralSecurityException
- if there's an issue decryptingpublic byte[] decrypt(javax.crypto.spec.SecretKeySpec key, byte[] iv, byte[] decodedCipherText) throws java.security.GeneralSecurityException
key
- AES key typically 128, 192 or 256 bitiv
- Initiation VectordecodedCipherText
- in bytes (assumed it's already been decoded)java.security.GeneralSecurityException
- if something goes wrong during encryption