Skip to content

Instantly share code, notes, and snippets.

@rkleine
rkleine / couchdb-password.js
Last active August 13, 2019 11:59
CouchDB 2.x NodeJS password generator
const crypto = require('crypto')
function generatePassword(password, options = {}) {
const { iterations = 1000, keylen = 20, digest = 'sha1', saltSize = 24 } = options
const salt = crypto.randomBytes(saltSize).toString('hex')
const key = crypto.pbkdf2Sync(password, salt, iterations, keylen, digest).toString('hex')
return {
iterations,
salt,
key
@rkleine
rkleine / cuit-cuil.js
Last active May 23, 2018 12:11
CUIT - CUIL
function generateCUIL(dni, type) {
if (dni.toString().length < 7) return false;
let xy = 30;
if (type === 'f') {
xy = 27;
} else if(type === 'm') {
xy = 20;
}