com.vaadin.flow.internal.

Class MessageDigestUtil

java.lang.Object
com.vaadin.flow.internal.MessageDigestUtil
public class MessageDigestUtil extends Object

Utility class for common MessageDigest operations.

For internal use only. May be renamed or removed in a future release.

Since:

1.0

Author:

Vaadin Ltd

  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    sha256(String string)

    Calculates the SHA-256 hash of the UTF-16 representation of the given string.

    static byte[]
    sha256(String string, byte[] salt, Charset charset)

    Calculates the SHA-256 hash of the given string with the given salt representation using the supplied charset.

    static byte[]
    sha256(String string, Charset charset)

    Calculates the SHA-256 hash of the given string representation using the supplied charset.

    static String
    sha256Hex(byte[] content)

    Calculates the SHA-256 hash of the given byte array.

    static String
    sha256Hex(byte[] content, byte[] salt)

    Calculates the SHA-256 hash of the given byte array with the given salt.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • sha256

      public static byte[] sha256(String string)

      Calculates the SHA-256 hash of the UTF-16 representation of the given string.

      Parameters:

      string - the string to hash

      Returns:

      32 bytes making up the hash

    • sha256

      public static byte[] sha256(String string, Charset charset)

      Calculates the SHA-256 hash of the given string representation using the supplied charset.

      Parameters:

      string - the string to hash

      Returns:

      32 bytes making up the hash

    • sha256

      public static byte[] sha256(String string, byte[] salt, Charset charset)

      Calculates the SHA-256 hash of the given string with the given salt representation using the supplied charset.

      Parameters:

      string - the string to hash

      salt - salt to be added into hash calculation

      Returns:

      32 bytes making up the hash

    • sha256Hex

      public static String sha256Hex(byte[] content)

      Calculates the SHA-256 hash of the given byte array.

      Parameters:

      content - the byte array to hash

      Returns:

      sha256 hash string

    • sha256Hex

      public static String sha256Hex(byte[] content, byte[] salt)

      Calculates the SHA-256 hash of the given byte array with the given salt.

      Parameters:

      content - the byte array to hash

      salt - salt to be added to the calculation

      Returns:

      sha256 hash string