Algobook
- The developer's handbook
mode-switch
back-button
Buy Me A Coffee
Sun May 14 2023

A free and open hashing API

In this short guide we will show how we can use a free and open hashing API to managing our passwords and other secrets.

Promotion tutorial

If you have read my articles before, you know that I from time to time do these promotion articles of our free APIs and open source projects that we provide on Algobook. Check out all our free software here.

Today is no different my friend, we will take a look at our Crypto API and brifly show how we can use it to hash our passwords and texts.

Encrypt

So if we want to encrypt a text, we can utilize the hash endpoint and provide the string in plain text.

Example in JavaScript:

const response = await fetch( "https://api.algobook.info/v1/crypto/hash?plain=my secret text" ); const data = await response.json(); console.log(data.hashed); // $2b$10$9EUT12.dCZ7s77XxlkiFSeEnNxBwxgxdtX584htGrhxJzb05uZBIu

And our text is now total gibberish for a potential hacker.

Decrypt

If we want to decrypt our hashed value, we can simlpy send the hash in together with the original text to see that it is the same. This function is designed to work on passwords, where the password that is inputed by the user is the same as the hashed value that are stored in the database.

Example in JavaScript:

const response = await fetch( "https://api.algobook.info/v1/crypto/validate?plain=my secret text&hashed=$2b$10$9EUT12.dCZ7s77XxlkiFSeEnNxBwxgxdtX584htGrhxJzb05uZBIu" ); const data = await response.json(); console.log(data.valid); // true

And if the hash and the plain text is the same, it will return true.

Outro

That's it for this short guide. As stated above, this was a little promotion tutorial of our free API. The API is using bcrypt in the background which is a very known algorithm for password hashing. I hope you found this interesting, and that you perhaps want to use our API, which is our goal here at Algobook!

All the best,

signatureSun May 14 2023
See all our articles