Klasse Salt

java.lang.Object
de.uplanet.security.Salt

@Scriptable public final class Salt extends Object
Used to create cryptographically secure random strings that can be used as salt values.
  • Feldübersicht

    Felder
    Modifizierer und Typ
    Feld
    Beschreibung
    static final int
    The default length of a salt string in bytes (16).
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    static String
    get()
    Create a cryptographically secure hex-encoded salt value of the default length in bytes.
    static String
    get(byte[] p_key, int p_iLen)
    Create a hex-encoded salt value of the given length in bytes.
    static String
    get(int p_iLen)
    Create a cryptographically secure hex-encoded salt value of the given length in bytes.
    static byte[]
    Create cryptographically secure salt value of the default length in bytes.
    static byte[]
    getBinary(byte[] p_key, int p_iLen)
    Create a salt value of the given length in bytes.
    static byte[]
    getBinary(int p_iLen)
    Create a cryptographically secure salt value of the given length in bytes.
    static byte[]
    toBinary(String p_strHex)
    Convert the given hex string to bytes.
    static String
    toHex(byte[] p_buf)
    Convert the given bytes to a hex-encoded string.

    Von Klasse geerbte Methoden java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Felddetails

    • DEFAULT_SALT_LENGTH

      public static final int DEFAULT_SALT_LENGTH
      The default length of a salt string in bytes (16).
      Siehe auch:
  • Methodendetails

    • get

      public static String get()
      Create a cryptographically secure hex-encoded salt value of the default length in bytes.

      Note that the length of the returned hex-encoded string is twice of the length in bytes.

      Gibt zurück:
      The hex-encoded salt value.
      Siehe auch:
    • getBinary

      public static byte[] getBinary()
      Create cryptographically secure salt value of the default length in bytes.
      Gibt zurück:
      The salt value.
      Siehe auch:
    • get

      public static String get(int p_iLen)
      Create a cryptographically secure hex-encoded salt value of the given length in bytes.

      Note that the length of the returned hex-encoded string is twice of the length in bytes.

      Parameter:
      p_iLen - The length of the salt value in bytes.
      Gibt zurück:
      The hex-encoded salt value.
    • getBinary

      public static byte[] getBinary(int p_iLen)
      Create a cryptographically secure salt value of the given length in bytes.
      Parameter:
      p_iLen - The length of the salt value in bytes.
      Gibt zurück:
      The salt value.
    • get

      public static String get(byte[] p_key, int p_iLen)
      Create a hex-encoded salt value of the given length in bytes.

      The created salt is only cryptographically secure if the provided key material is cryptographically secure, i.e. contains cryptographically secure random bits.

      The derived salt value contains at most 256 bits of entropy.

      The given key material cannot be recovered from the generated salt.

      Note that the length of the returned hex-encoded string is twice of the length in bytes.

      Parameter:
      p_key - The key material that determines the value of the salt.
      p_iLen - The length of the salt value in bytes.
      Gibt zurück:
      The hex-encoded salt value.
    • getBinary

      public static byte[] getBinary(byte[] p_key, int p_iLen)
      Create a salt value of the given length in bytes.

      The created salt is only cryptographically secure if the provided key material is cryptographically secure, i.e. contains cryptographically secure random bits.

      The derived salt value contains at most 256 bits of entropy.

      The given key material cannot be recovered from the generated salt.

      Parameter:
      p_key - The key material that determines the value of the salt.
      p_iLen - The length of the salt value in bytes.
      Gibt zurück:
      The salt value.
    • toHex

      public static String toHex(byte[] p_buf)
      Convert the given bytes to a hex-encoded string.
      Parameter:
      p_buf - The bytes to convert
      Gibt zurück:
      The hex-encoded bytes.
    • toBinary

      public static byte[] toBinary(String p_strHex)
      Convert the given hex string to bytes.
      Parameter:
      p_strHex - A string of hex-encoded bytes.
      Gibt zurück:
      The decoded bytes.
      Löst aus:
      IllegalArgumentException - If the input length is odd or if the input contains non-hexadecimal digits.