Class StringDigester

  • All Implemented Interfaces:
    Function<String,​String>

    public class StringDigester
    extends Object
    implements Function<String,​String>
    A function impl which accepts a String input, digests it according to a specified MessageDigest algorithm, and then returns the output in a specified format: Base64-encoded or hexadecimal with with lower or upper case characters.
    • Field Detail

      • DEFAULT_INPUT_CHARSET

        @Nonnull
        public static final Charset DEFAULT_INPUT_CHARSET
        The default input character set.
      • log

        @Nonnull
        private final org.slf4j.Logger log
        Logger.
      • digestAlgorithm

        @Nonnull
        @NotEmpty
        private String digestAlgorithm
        The message digest algorithm to use.
      • outputFormat

        @Nonnull
        private StringDigester.OutputFormat outputFormat
        The output format instance used to determine how the digested byte[] is converted to the output String.
      • inputCharset

        @Nonnull
        private Charset inputCharset
        The Charset instance used in converting the input String to a byte[].
      • salt

        @Nullable
        private String salt
        Optional salt to add into the digest.
      • requireSalt

        private boolean requireSalt
        Whether to require a salt to return any output.
    • Method Detail

      • setSalt

        public void setSalt​(@Nullable @NotEmpty
                            String s)
        Set a salt to add to the digest input for obfuscation.
        Parameters:
        s - salt value
      • setRequireSalt

        public void setRequireSalt​(boolean flag)
        Set whether to return any data if no salt is set.
        Parameters:
        flag - flag to set