Skip to content

Instantly share code, notes, and snippets.

Last active September 24, 2022 23:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Calculate how true something is
const crypto = require('crypto');
const truths = [
'so true',
'undeniably true',
'This response is undeniably true;',
'So true!',
'This is true;',
function sentenceHash (sentence) {
const symbols = sentence
.filter(char => 'abcdefghijklmnopqrstuvwxyz123456789'.split('').includes(char))
return crypto.createHash('md5').update(symbols + process.env.HOWTRUE_SALT).digest('hex');
function howTrue (text) {
return truths[parseInt(sentenceHash(text).substring(0, 5), 16) % truths.length];
module.exports = async function (req, res, [ text ]) {
res.header('Hash-Output', sentenceHash(text));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment