Interface PwHash.Lazy

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String cryptoPwHash​(java.lang.String password, int cryptoPwHashLen, byte[] salt, long opsLimit, com.sun.jna.NativeLong memLimit, PwHash.Alg alg)
      Hashes a given password.
      java.lang.String cryptoPwHashStr​(java.lang.String password, long opsLimit, com.sun.jna.NativeLong memLimit)
      The most minimal way of hashing a given password.
      java.lang.String cryptoPwHashStrRemoveNulls​(java.lang.String password, long opsLimit, com.sun.jna.NativeLong memLimit)
      Hashes a string and removes all the null bytes.
      boolean cryptoPwHashStrVerify​(java.lang.String hash, java.lang.String password)
      Verifies a password.
    • Method Detail

      • cryptoPwHashStr

        java.lang.String cryptoPwHashStr​(java.lang.String password,
                                         long opsLimit,
                                         com.sun.jna.NativeLong memLimit)
                                  throws SodiumException
        The most minimal way of hashing a given password. We auto-generate the salt and use the default hashing algorithm PwHash.Alg.
        Parameters:
        password - The password string to hash.
        opsLimit - The number of cycles to perform whilst hashing. Between PwHash.OPSLIMIT_MIN and PwHash.OPSLIMIT_MAX.
        memLimit - The amount of memory to use. Between PwHash.MEMLIMIT_MIN and PwHash.MEMLIMIT_MAX.
        Returns:
        The hashed password
        Throws:
        SodiumException - If the password could not be hashed.
      • cryptoPwHashStrRemoveNulls

        java.lang.String cryptoPwHashStrRemoveNulls​(java.lang.String password,
                                                    long opsLimit,
                                                    com.sun.jna.NativeLong memLimit)
                                             throws SodiumException
        Hashes a string and removes all the null bytes. Uses the hashing algorithm PwHash.Alg.
        Parameters:
        password - The password string to hash.
        opsLimit - The number of cycles to perform whilst hashing. Between PwHash.OPSLIMIT_MIN and PwHash.OPSLIMIT_MAX.
        memLimit - The amount of memory to use. Between PwHash.MEMLIMIT_MIN and PwHash.MEMLIMIT_MAX.
        Returns:
        The hash without null bytes at the end. WARNING: when verifying please remember to ADD a null byte to the end!
        Throws:
        SodiumException - If the password could not be hashed.
      • cryptoPwHashStrVerify

        boolean cryptoPwHashStrVerify​(java.lang.String hash,
                                      java.lang.String password)
        Verifies a password. Good news: this function automatically adds a null byte to the end which is required for the native underlying function to work.
        Parameters:
        hash - The hash. Must be hexadecimal Helpers.Lazy.sodiumBin2Hex(byte[]).
        password - The password.
        Returns:
        True if the password 'unlocks' the hash.