- java.lang.Object
-
- dev.netcode.security.encryption.AESEncrypter
-
public class AESEncrypter extends java.lang.ObjectThis utility class can be used to encrypt and decrypt data using the AES encryption algorithm.
-
-
Constructor Summary
Constructors Constructor Description AESEncrypter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static dev.netcode.util.Result<java.lang.String>decrypt(java.lang.String message, java.lang.String password)Decrypts a message using a given password and returns it as String.static dev.netcode.util.Result<java.lang.String>encrypt(java.lang.String message, java.lang.String password)Encrypts a message using a given password and returns it as Base64 encrypted String.static javax.crypto.spec.SecretKeySpecgetKey(java.lang.String password)Generates aSecretKeySpecfrom a password to be used for AES encryption
-
-
-
Method Detail
-
getKey
public static javax.crypto.spec.SecretKeySpec getKey(java.lang.String password)
Generates aSecretKeySpecfrom a password to be used for AES encryption- Parameters:
password- to generate theSecretKeySpecfor- Returns:
- the generated
SecretKeySpec
-
encrypt
public static dev.netcode.util.Result<java.lang.String> encrypt(java.lang.String message, java.lang.String password)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
public static dev.netcode.util.Result<java.lang.String> decrypt(java.lang.String message, java.lang.String password)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
-
-