chickadee » gromit » define-property-constructor

(define-property-constructor name type proc)syntax

Defines a constructor, `proc`, for a property type. `proc` takes a freshly made, but uninitialised, property as its first argument. Any subsequent arguments are user defined. `proc` then manipulates the provided property using the regular property accessors. When `proc` has finished executing, the constructed property is returned to the user. The return value of `proc` is ignored.

  (define-property-constructor make-password* password
    (lambda (p plaintext)
      ; https://ruby-doc.org/stdlib-2.0.0/libdoc/openssl/rdoc/OpenSSL/PKCS5.html
      (let ((iterations 10000)
  	  (salt       (make-salt 32)) ; 256 bits matching 256 bit digest function.
  	  (dklen      32))            ; (/ 256 8)
        (password-algorithm  p 'pbkdf2-hmac-sha256)
        (password-iterations p iterations)
        (password-salt       p salt)
        (password-crypt      p (pbkdf2-hmac-sha256 plaintext salt iterations dklen 'blob)))))