A simple password-based encryption utility is available as a demonstration of
the scrypt
library. It can be invoked as scrypt {key} {salt} {rounds}
{memcost} [-P]
. The utility will ask for a plain text password and output a
hash upon success. This hash should be encoded to base64 and compared to the
password hash of the exported user account.
- {key} - The signer key from the project's password hash parameters. This key
must be decoded from base64 before being passed to the utility.
- {salt} - Concatenation of the password salt from the exported account and the
salt separator from the project's password hash parameters. Each half must be
decoded from base64 before concatenation.
- {rounds} - The rounds parameter from the project's password hash parameters.
- {memcost} - The mem_cost parameter from the project's password hash
parameters.
- [-P] - An optional
-P
may also be supplied to allow for the raw text
password to be read from STDIN.
Sample Password hash parameters from Firebase Console:
hash_config {
algorithm: SCRYPT,
base64_signer_key: jxspr8Ki0RYycVU8zykbdLGjFQ3McFUH0uiiTvC8pVMXAn210wjLNmdZJzxUECKbm0QsEmYUSDzZvpjeJ9WmXA==,
base64_salt_separator: Bw==,
rounds: 8,
mem_cost: 14,
}
Exporting a project's accounts:
# Export a project's accounts to a local csv file
$ firebase auth:export --project my-awesome-project-42be4 users.csv
# Inspect the exported accounts
$ cat users.csv
kYi4EvWQlQTKSfnJ3dRSP6IH3ed2,user1@test.com,false,lSrfV15cpx95/sZS2W9c9Kp6i/LVgQNDNC/qzrCnh1SAyZvqmZqAjTdn3aoItz+VHjoZilo78198JAdRuid5lQ==,42xEC+ixf3L2lw==,Test
User 1,,,,,,,,,,,,,,,,,,,1508893925000,1508893925000,,
Using the utility:
# Params from the project's password hash parameters
base64_signer_key="jxspr8Ki0RYycVU8zykbdLGjFQ3McFUH0uiiTvC8pVMXAn210wjLNmdZJzxUECKbm0QsEmYUSDzZvpjeJ9WmXA=="
base64_salt_separator="Bw=="
rounds=8
memcost=14
# Params from the exported account
base64_salt="42xEC+ixf3L2lw=="
# The users raw text password
password="user1password"
# Generate the hash
# Expected output:
# lSrfV15cpx95/sZS2W9c9Kp6i/LVgQNDNC/qzrCnh1SAyZvqmZqAjTdn3aoItz+VHjoZilo78198JAdRuid5lQ==
echo `./scrypt "$base64_signer_key" "$base64_salt" "$base64_salt_separator" "$rounds" "$memcost" -P <<< "$password"`