/sodiumoxide-password-hashing-examples

Examples of password hashing using the rust crate sodiumoxide. Includes DB examples using sqlx and postgres.

Primary LanguageRust

sodiumoxide password hashing examples

This repo was created to go with a blog post I wrote about using sodiumoxide for storing and verifying password hashes.

When I started playing with it I didn't find a lot of examples or explicit information on how to use the library so I decided to do some research and attempt to make an ELI5 type post.

You can read the post here: https://blue42.net.

database setup

To run the database examples you'll need a postgres database and to set an environment variable with the connection string.

Example DATABASE_URL

export DATABASE_URL=postgres://postgres:postgres_user_password@localhost/database_name

Run a local postgres DB via docker

If you don't have a db available, but do have docker you can run a small container locally for testing.

## create the db and container
## !! don't forget to change the postgres_user_password !!

docker run -d --name pgsql12 \
        -e POSTGRES_PASSWORD=postgres_user_password \
        -p 5432:5432 \
        postgres:12-alpine

## to start the db in the future

docker start pgsql12

# to stop the db in the future

docker stop pgsql12