Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function EVP_BytesToKey (password, salt, keyLen, ivLen) {
if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary')
if (salt) {
if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary')
if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length')
}
var key = Buffer.alloc(keyLen)
var iv = Buffer.alloc(ivLen)
var tmp = Buffer.alloc(0)
while (keyLen > 0 || ivLen > 0) {
var hash = new MD5()
hash.update(tmp)
hash.update(password)
if (salt) hash.update(salt)
tmp = hash.digest()
var used = 0
if (keyLen > 0) {
var keyStart = key.length - keyLen
used = Math.min(keyLen, tmp.length)
tmp.copy(key, keyStart, 0, used)
keyLen -= used
}
if (used < tmp.length && ivLen > 0) {
var ivStart = iv.length - ivLen
function EVP_BytesToKey (password, salt, keyBits, ivLen) {
if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary')
if (salt) {
if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary')
if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length')
}
var keyLen = keyBits / 8
var key = Buffer.alloc(keyLen)
var iv = Buffer.alloc(ivLen || 0)
var tmp = Buffer.alloc(0)
while (keyLen > 0 || ivLen > 0) {
var hash = new MD5()
hash.update(tmp)
hash.update(password)
if (salt) hash.update(salt)
tmp = hash.digest()
var used = 0
if (keyLen > 0) {
var keyStart = key.length - keyLen
used = Math.min(keyLen, tmp.length)
tmp.copy(key, keyStart, 0, used)
keyLen -= used
}
if (used < tmp.length && ivLen > 0) {
var ivStart = iv.length - ivLen
export const md5 = (str, salt='winwinfe') => new MD5().update(str + salt).digest('hex');
.map(error => ({
description: error.ruleName + ': ' + error.failure,
fingerprint: new MD5().update(JSON.stringify(error)).digest('hex'),
location: {
path: error.name.replace(process.cwd() + '/', ''),
lines: {
begin: error.startPosition.line + 1,
},
},
}));
constructor(params: ChallengeParams, username: string, password: string) {
const realm = params.get('realm')
if (realm === undefined) {
throw new Error('no realm in digest challenge')
}
this.realm = realm
this.ha1Base = new MD5()
.update(`${username}:${realm}:${password}`)
.digest('hex')
const nonce = params.get('nonce')
if (nonce === undefined) {
throw new Error('no nonce in digest challenge')
}
this.nonce = nonce
this.opaque = params.get('opaque')
const algorithm = params.get('algorithm')
if (algorithm !== undefined) {
if (algorithm === 'md5') {
this.algorithm = 'md5'
} else if (algorithm === 'md5-sess') {
module.exports = function (buffer) {
return new MD5().update(buffer).digest()
}
config.currentUser.blockedUserHashes, h =>
new MD5( ).update( item.user.id.toString( ) ).digest( "hex" ) === h
)
module.exports = function createHash (alg) {
alg = alg.toLowerCase()
if (alg === 'md5') return new MD5()
if (alg === 'rmd160' || alg === 'ripemd160') return new RIPEMD160()
return new Hash(sha(alg))
}
module.exports = function (buffer) {
return new MD5().update(buffer).digest()
}