Skip to content

glotlabs/argon2-cloudflare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

argon2-cloudflare

Cloudflare worker for hashing and verifying passwords with argon2. Can be used via a service binding.

Dev

Install deps

npm install

Dev server

npm run dev

Deploy to cloudflare

npm deploy

Api

Hash

Endpoint

POST /hash

Request
{
    "password": "foo"
}

or with options:

{
    "password": "some-password",
    "options": {
        "timeCost": 2,
        "memoryCost": 19456,
        "parallelism": 1
    }
}
Response
{
    "hash": "$argon2id$v=19$m=19456,t=2,p=1$2FtyxY2Dz8nfis44QbdqUA$+HDTT2BgERMyXEEX/o2LbKdROHzQeL4VWbyM7U0p8Ag"
}

Verify

Endpoint

POST /verify

Request
{
    "password": "foo",
    "hash": "$argon2id$v=19$m=19456,t=2,p=1$2FtyxY2Dz8nfis44QbdqUA$+HDTT2BgERMyXEEX/o2LbKdROHzQeL4VWbyM7U0p8Ag"
}
Response
{
    "matches": true,
}

Service binding from pages function

interface Env {
  ARGON2: Fetcher;
}

export const onRequestPost: PagesFunction<Env> = async (context) => {
  const resp = await context.env.ARGON2.fetch("http://internal/hash", {
    method: "POST",
    body: JSON.stringify({ password: "foo" }),
  });

  const { hash } = await resp.json();
  console.log(hash);
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages