Class SCryptEncoder


  • public class SCryptEncoder
    extends 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 Detail

      • SCryptEncoder

        public SCryptEncoder​(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