Class SCryptEncoder


  • public class SCryptEncoder
    extends java.lang.Object
    Uses scrypt to encode passwords. The class limits number of concurrent encodings so that we can have a control about the total memory use by scrypt. Scrypt memory appetite is: 128 bytes × 2^workFactor × blockSize. With default block size of 8, it is 1024 x 2^workfactor.
    • Constructor Summary

      Constructors 
      Constructor Description
      SCryptEncoder​(java.util.concurrent.ForkJoinPool pool)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getMaxAllowedWorkFactor()
      Computes a max currently considered safe work factor, taking into account the heap memory available for the VM and the configured number of allowed concurrent password checks.
      byte[] scrypt​(java.lang.String password, byte[] salt, ScryptParams params)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SCryptEncoder

        public SCryptEncoder​(java.util.concurrent.ForkJoinPool pool)
    • Method Detail

      • getMaxAllowedWorkFactor

        public int getMaxAllowedWorkFactor()
        Computes a max currently considered safe work factor, taking into account the heap memory available for the VM and the configured number of allowed concurrent password checks. Algorithm assumes 0.5G heap reserved for other purposes then password hashing (pretty arbitrary number, typically well enough, but may happen this is to low).
        Returns:
        max WF so that 1024*2^WF < MAX_AVAILABLE_HEAP - 500MB
      • scrypt

        public byte[] scrypt​(java.lang.String password,
                             byte[] salt,
                             ScryptParams params)