java.lang.Object
dev.netcode.security.encryption.AESEncrypter
This utility class can be used to encrypt and decrypt data using
the AES encryption algorithm.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic dev.netcode.util.Result<String>Decrypts a message using a given password and returns it as String.static dev.netcode.util.Result<String>Encrypts a message using a given password and returns it as Base64 encrypted String.static SecretKeySpecGenerates aSecretKeySpecfrom a password to be used for AES encryption
-
Constructor Details
-
AESEncrypter
public AESEncrypter()
-
-
Method Details
-
getKey
Generates aSecretKeySpecfrom a password to be used for AES encryption- Parameters:
password- to generate theSecretKeySpecfor- Returns:
- the generated
SecretKeySpec
-
encrypt
Encrypts a message using a given password and returns it as Base64 encrypted String. For encryption the cipher instance ofAES/ECB/PKCS5PADDINGis used- Parameters:
message- to be encryptedpassword- to be used to encrypt the message- Returns:
- encrypted message wrapped inside
Result
-
decrypt
Decrypts a message using a given password and returns it as String. It is assumed that the message is encrypted usingAES/ECB/PKCS5PADDINGand transformed to Base64.- Parameters:
message- to be decryptedpassword- to be used to decrypt the message- Returns:
- decrypted message wrapped inside
Result
-