Package io.token.security.cipher.aes
Class AesEncrypter
- java.lang.Object
-
- io.token.security.cipher.aes.AesEncrypter
-
-
Constructor Summary
Constructors Constructor Description AesEncrypter(java.lang.String algorithm, javax.crypto.SecretKey encryptionKey)
Creates an encrypter for the specified key using specific encryption algorithms.AesEncrypter(javax.crypto.SecretKey encryptionKey)
Creates an encrypter for the specified key using default encryption algorithms.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
encrypt(java.lang.String text)
Encrypts the specified text using a symmetric key.java.lang.String
getAlgorithm()
Returns the algorithm name of the encrypter.
-
-
-
Constructor Detail
-
AesEncrypter
public AesEncrypter(javax.crypto.SecretKey encryptionKey)
Creates an encrypter for the specified key using default encryption algorithms.- Parameters:
encryptionKey
- the public key to be used for encryption
-
AesEncrypter
public AesEncrypter(java.lang.String algorithm, javax.crypto.SecretKey encryptionKey)
Creates an encrypter for the specified key using specific encryption algorithms.- Parameters:
algorithm
- the encryption algorithmencryptionKey
- the public key to be used for encryption
-
-
Method Detail
-
getAlgorithm
public java.lang.String getAlgorithm()
Description copied from interface:Encrypter
Returns the algorithm name of the encrypter.- Specified by:
getAlgorithm
in interfaceEncrypter
- Returns:
- the name of the algorithm
-
encrypt
public java.lang.String encrypt(java.lang.String text)
Encrypts the specified text using a symmetric key. The produced ciphertext is prepended with the IV used by the encrypter.The data is represented in the following format:
[iv size] [tag size] [iv data] [ciphertext]
1. The first byte is the size of the iv;
2. followed by the iv data of the size from #1;
3. then followed by the ciphertext bytes.
-
-