Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function iter(block) {
let hash = createHash(opts.digest || 'md5');
hash.update(block);
hash.update(data);
hash.update(salt);
block = hash.digest();
for (let e = 1; e < (opts.count || 1); e++) {
hash = createHash(opts.digest || 'md5');
hash.update(block);
block = hash.digest();
}
return block;
}
function verify(transaction) {
let remove = 64;
if (transaction.signSignature) {
remove = 128;
}
const bytes = getBytes(transaction);
const data2 = Buffer.alloc(bytes.length - remove);
for (let i = 0; i < data2.length; i++) {
data2[i] = bytes[i];
}
const hash = crypto.createHash('sha256').update(data2.toString('hex'), 'hex').digest();
const signatureBuffer = Buffer.from(transaction.signature, 'hex');
const senderPublicKeyBuffer = Buffer.from(transaction.senderPublicKey, 'hex');
const res = naclInstance
.crypto_sign_verify_detached(signatureBuffer, hash, senderPublicKeyBuffer);
return res;
}
Accounts.prototype.generateAddressByPublicKey = function (publicKey) {
var publicKeyHash = crypto.createHash("sha256").update(publicKey, "hex").digest();
var temp = new Buffer(8);
for (var i = 0; i < 8; i++) {
temp[i] = publicKeyHash[7 - i];
}
var address = bignum.fromBuffer(temp).toString() + "L";
return address;
}
public static hash(obj) {
let hash = createHash('sha256');
let result = ulotionHelper.stringify(obj);
return hash.update(result, 'utf8').digest().toString('hex');
}
public hash(value: string) {
const hashScriptBuffer = crypto.createHash("sha256").update(value).digest();
return new RIPEMD160().update(hashScriptBuffer).digest("hex");
}
Crypto.prototype.keypair = function (secret) {
var hash = crypto.createHash("sha256").update(secret, "utf8").digest();
var kp = nacl_instance.crypto_sign_keypair_from_seed(hash);
var keypair = {
publicKey: new Buffer(kp.signPk).toString("hex"),
privateKey: new Buffer(kp.signSk).toString("hex")
}
return keypair;
}
function createLoginUrlWithVerifier() {
const verifier = base64url(uuidv4());
const challenge = base64url(
crypto
.createHash('sha256')
.update(verifier)
.digest()
);
const loginUrl = `${authDomain}/oauth2/authorize?${new URLSearchParams({
...authParams,
redirect_uri: getRedirectUrl(),
code_challenge: challenge,
code_challenge_method: 'S256',
}).toString()}`;
return { loginUrl, verifier };
}
Round.prototype.generateDelegateList = function (height) {
var seedSource = self.calc(height).toString();
var delegates = private.delegates.slice(0);
var currentSeed = crypto.createHash("sha256").update(seedSource, "utf8").digest();
for (var i = 0, delCount = delegates.length; i < delCount; i++) {
for (var x = 0; x < 4 && i < delCount; i++, x++) {
var newIndex = currentSeed[x] % delCount;
var b = delegates[newIndex];
delegates[newIndex] = delegates[i];
delegates[i] = b;
}
currentSeed = crypto.createHash("sha256").update(currentSeed).digest();
}
return delegates;
}
createHash: () => require('crypto-browserify').createHash('sha1'),
};
function iter(block) {
let hash = createHash(opts.digest || 'md5');
hash.update(block);
hash.update(data);
hash.update(salt);
block = hash.digest();
for (let e = 1; e < (opts.count || 1); e++) {
hash = createHash(opts.digest || 'md5');
hash.update(block);
block = hash.digest();
}
return block;
}