java.lang.Object
es.kukenan.smartfi.microservice.firm.service.security.Cipher

@Component public class Cipher extends Object
Component used to cypher sensible information stored in unsecured media.
  • Field Details

    • CHARSET

      private static final Charset CHARSET
      Charset to use to get buffer from configuration.
    • seed

      private final byte[] seed
      The key material of the secret key.
    • uuid

      private final byte[] uuid
      The buffer with the IV.
    • algorithm

      @Value("${cipher.algorithm}") private String algorithm
      Cipher algorithm.
  • Constructor Details

    • Cipher

      public Cipher(@Value("${cipher.seed}") String seed, @Value("${cipher.uuid}") String uuid)
      Cipher constructor.
      Parameters:
      seed - a string the key material of the secret key.
      uuid - a string with the buffer with the IV.
  • Method Details

    • encrypt

      public String encrypt(String hash)
      Encrypts the given text using the configured cipher specification.
      Parameters:
      hash - the text to encrypt.
      Returns:
      encrypted text, in base 64 format.
    • decrypt

      public String decrypt(String hash)
      Decrypts the given text using the configured cipher specification.
      Parameters:
      hash - the data to decrypt, in Base64 format.
      Returns:
      encrypted text.