Skip to content

Instantly share code, notes, and snippets.

Avatar

Carl Johnson carlmjohnson

View GitHub Profile
@carlmjohnson
carlmjohnson / crypto-rand.js
Last active May 28, 2020 — forked from paragonie-scott/gist:c7a73fd0f759e451cf07
Javascript CSPRNG for Integers
View crypto-rand.js
function secureRand(min, max) {
let range = max - min;
if (range < 2) {
return min;
}
let bits_needed = Math.ceil(Math.log2(range));
if (bits_needed > 31) {
throw new Error("cannot generate numbers larger than 31 bits.");
}
@carlmjohnson
carlmjohnson / tot
Last active Feb 28, 2020 — forked from zrzka/!IMPORTANT.md
A shell script for Tot
View tot
#!/usr/bin/env bash
# Fork of gruber's tot.sh https://gist.github.com/gruber/b18d8b53385fa612713754799ed4d0a2
# which is a fork of chockenberry's tot.sh https://gist.github.com/chockenberry/d33ef5b6e6da4a3e4aa9b07b093d3c23
#
# WARNING some options have different & potentially destructive meaning, for example:
# -r gets the dot contents in original script, but this one REPLACES the dot contents
# and does use -p to get the dot contents
#
You can’t perform that action at this time.