Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8928533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:27:34+00:00 2026-06-15T08:27:34+00:00

I would like to use scrypt to create a hash for my users’ passwords

  • 0

I would like to use scrypt to create a hash for my users’ passwords and salts. I have found two references, but there are things I don’t understand about them.

They use the scrypt encrypt and decrypt functions. One encrypts a random string and the other encrypts the salt (which looks wrong since only the password and not the salt is used for decryption). It looks like the decrypt function is being used to validate the password/salt as a side effect of the decryption.

Based on the little I understand, what I want is a key derivation function (KDF) rather than encryption/decryption and that the KDF is likely generated and used by scrypt for encryption/decryption. The actual KDF is used behind the scenes and I am concerned that blindly following these examples will lead to a mistake. If the scrypt encrypt/decrypt functions are used to generate and verify the password, I don’t understand the role of the string being encrypted. Does its content or length matter?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:27:35+00:00Added an answer on June 15, 2026 at 8:27 am

    You’re correct – the scrypt functions those two links are playing with are the scrypt file encryption utility, not the underlying kdf. I’ve been slowly working on creating a standalone scrypt-based password hash for python, and ran into this issue myself.

    The scrypt file utility does the following: picks scrypt’s n/r/p parameters specific to your system & the “min time” parameter. It then generates a 32 byte salt, and then calls scrypt(n,r,p,salt,pwd) to create a 64 bytes key. The binary string the tool returns is composed of: 1) a header containing n, r, p values, and the salt encoded in binary; 2) an sha256 checksum of the header; and 3) a hmac-sha256 signed copy of the checksum, using the first 32 bytes of the key. Following that, it uses the remaining 32 bytes of the key to AES encrypt the input data.

    There are a couple of implications of this that I can see:

    1. the input data is meaningless, since it doesn’t actually affect the salt being used, and encrypt() generates a new salt each time.

    2. you can’t configure the n,r,p workload manually, or any other way but the awkward min-time parameter. this isn’t insecure, but is a rather awkward way to control the work factor.

    3. after the decrypt call regenerates the key and compares it against the hmac, it will reject everything right there if your password is wrong – but if it’s right, it’ll proceed to also decrypt the data package. This is a lot of extra work the attacker won’t have to perform – they don’t even have to derive 64 bytes, just the 32 needed to check the signature. This issue doesn’t make it insecure exactly, but doing work your attacker doesn’t is never desirable.

    4. there is no way to configure salt key, derived key size, etc. the current values aren’t that bad, but still, it’s not ideal.

    5. the decrypt utility’s “max time” limitation is wrong for password hashing – each time decrypt is called, it estimates your system’s speed, and does some “guessing” as to whether it can calculate the key within max time – which is more overhead your attacker doesn’t have to do (see #3), but it also means decrypt could start rejecting passwords under heavy system load.

    6. I’m not sure why Colin Percival didn’t make the kdf & parameter-choosing code part of the public api, but it’s infact explicitly marked “private” inside the source code – not even exported for linking. This makes me hesitant to just access it straight without a lot more study.

    All in all, what is needed is a nice hash format that can store scrypt, and an implementation that exposes the underlying kdf and parameter-choosing algorithm. I’m currently working on this myself for passlib, but it hasn’t seen much attention 🙁

    Just to bottom line things though – those site’s instructions are ‘ok’, I’d just use an empty string as the file content, and be aware of the extra overhead and issues.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of Integers in Java, I would like use only a
I would like to use the logout function from Django but not sure how
I would like to use the MFMailComposeViewController mailComposeDelegate property with completion block syntax, but
I have written a small Perl script and now I would like to create
I would like to use the universal code and have ran into difficulties getting
I have a project that creates a disk image and would like to use
I would like to create a density plot using basemap. The data I have
I would like to use this script https://github.com/jeromeetienne/jquery-qrcode (or is there even a better
I would like to use the jenkins script console some more. Where do I
I would like to use R to extract the speaker out of scripts formatted

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.