Class AESEncrypter

java.lang.Object
dev.netcode.security.encryption.AESEncrypter

public class AESEncrypter extends Object
This utility class can be used to encrypt and decrypt data using the AES encryption algorithm.
  • Constructor Details

    • AESEncrypter

      public AESEncrypter()
  • Method Details

    • getKey

      public static SecretKeySpec getKey(String password)
      Generates a SecretKeySpec from a password to be used for AES encryption
      Parameters:
      password - to generate the SecretKeySpec for
      Returns:
      the generated SecretKeySpec
    • encrypt

      public static dev.netcode.util.Result<String> encrypt(String message, String password)
      Encrypts a message using a given password and returns it as Base64 encrypted String. For encryption the cipher instance of AES/ECB/PKCS5PADDING is used
      Parameters:
      message - to be encrypted
      password - to be used to encrypt the message
      Returns:
      encrypted message wrapped inside Result
    • decrypt

      public static dev.netcode.util.Result<String> decrypt(String message, String password)
      Decrypts a message using a given password and returns it as String. It is assumed that the message is encrypted using AES/ECB/PKCS5PADDING and transformed to Base64.
      Parameters:
      message - to be decrypted
      password - to be used to decrypt the message
      Returns:
      decrypted message wrapped inside Result