Class CryptoDigestService

java.lang.Object
com.eurodyn.qlack.fuse.crypto.service.CryptoDigestService

@Service @Validated public class CryptoDigestService extends Object
Message digest algorithms.
  • Constructor Details

    • CryptoDigestService

      public CryptoDigestService()
  • Method Details

    • hmacSha256

      public String hmacSha256(String secret, String message) throws NoSuchAlgorithmException, InvalidKeyException
      HMAC with SHA256.
      Parameters:
      secret - the secret to use
      message - the message to hash
      Returns:
      the generated encoding
      Throws:
      NoSuchAlgorithmException - thrown when no algorithm is found for encryption
      InvalidKeyException - thrown when the provided key is invalid
    • sha256

      public String sha256(String message)
      Calculates the SHA256 of the given string.
      Parameters:
      message - the message to hash
      Returns:
      the SHA256 values
    • sha256

      public String sha256(InputStream inputStream) throws IOException
      Calculates the SHA256 of the InputStream.
      Parameters:
      inputStream - the input stream to hash
      Returns:
      the SHA256 value
      Throws:
      IOException - thrown when something unexpected happens
    • generateSecureRandom

      public String generateSecureRandom(int length) throws NoSuchAlgorithmException
      Generates a random seed.
      Parameters:
      length - the number of bytes of the seed. Note that this is *not* the length of the return value as the return value is Base64 encoded
      Returns:
      a Base64 encoded version of the generated seed
      Throws:
      NoSuchAlgorithmException - thrown when no algorithm is found for encryption
    • md5

      @Deprecated public String md5(String message)
      Deprecated.
      Prefer the SHA256 alternatives.
      Calculates the MD5 of the given string.
      Parameters:
      message - The message to hash.