Skip to content

Instantly share code, notes, and snippets.

View Meldiron's full-sized avatar
🔥

Matej Bačo Meldiron

🔥
View GitHub Profile
@Meldiron
Meldiron / scrypt-modified.md
Created June 17, 2022 09:11
What is Scrypt Modified? 🤔

Scrypt is a hashing algorithm first published in 2009 to address the security of passwords stored in a database. Generating such a hash is computationally intensive, meaning it takes a "long" time to generate a hash. This is fast enough for the sign-in process but makes it extremely costly to attempt brute-force to crack an existing password's hash.

SCrypt Modified is a fork of this algorithm. From its documentation, the intentions of the fork are unclear.

While official SCrypt takes password and salt to generate the hash, modified has a few additional steps:

  1. Generate derivedKey by creating a Scrypt hash where password is utf8-encoded, and salt is base64-decoded salt + base64-decoded salt separator
  2. Generate hash by encrypting base64-decoded signerKey with aes-256-ctr where key is the first 32 characters of derivedKey, while using an empty initialization vector of length 16
  3. Final hash must be base64-encoded
@Meldiron
Meldiron / timezone-awareness.js
Created September 6, 2022 08:55
Methods for converting dates between input type="datetime-local" and server-acceptable ISO 8610 format with timezone awareness.
function prefixWithZero(value, minLength = 2) {
value = value + "";
while (value.length < minLength) {
value = `0${value}`;
}
return value;
}
@Meldiron
Meldiron / setup.sh
Last active February 9, 2025 20:42
Ubuntu setup for multi-site wordpress hosting
# 1. Install Docker (https://get.docker.com/)
curl -fsSL https://get.docker.com -o install-docker.sh
sudo sh install-docker.sh
# 2. Setup Caddy
mkdir -p caddy
cd caddy
mkdir -p conf
nano conf/Caddyfile