Class AESUtils

java.lang.Object
io.adabox.dextreme.utils.AESUtils

public class AESUtils extends Object
AES Utils Used to Decrypt Responses for Minswap DEX API
  • Constructor Details

    • AESUtils

      public AESUtils()
  • Method Details

    • setKey

      public static void setKey(String myKey)
    • encrypt

      public static String encrypt(String strToEncrypt, String secret)
    • decrypt

      public static String decrypt(String cipherText, String secret)
      decrypt
      Parameters:
      cipherText - text to decrypt
      secret - secret used to decrypt
      Returns:
      decrypted string
    • GenerateKeyAndIV

      public static byte[][] GenerateKeyAndIV(int keyLength, int ivLength, int iterations, byte[] salt, byte[] password, MessageDigest md)
      Generates a key and an initialization vector (IV) with the given salt and password.

      This method is equivalent to OpenSSL's EVP_BytesToKey function (see https://github.com/openssl/openssl/blob/master/crypto/evp/evp_key.c). By default, OpenSSL uses a single iteration, MD5 as the algorithm and UTF-8 encoded password data.

      Parameters:
      keyLength - the length of the generated key (in bytes)
      ivLength - the length of the generated IV (in bytes)
      iterations - the number of digestion rounds
      salt - the salt data (8 bytes of data or null)
      password - the password data (optional)
      md - the message digest algorithm to use
      Returns:
      an two-element array with the generated key and IV