Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
trackEvent (event) {
// identify
if (size(event.user)) {
const user = event.user || {}
if (user.email) {
this.setEmailHash(sha256(user.email.trim()).toString())
}
if (user.anonymousId) {
this.setAnonymousId(user.anonymousId)
}
if (user.userId) {
this.setUserId(String(user.userId))
}
}
if (event.name === VIEWED_PAGE && event.website) {
this.website = this.filters.filterWebsite(event.website)
}
// for SPA apps we create campaign only on first pageview
if (event.name === VIEWED_PAGE) this.viewedPageCounter += 1
this.sendEventHit(event)
function hash(value) {
return SHA256(value); // eslint-disable-line
}
function hash(value) {
return SHA256(value); // eslint-disable-line
}
function hash(value) {
return SHA256(value);
}
export const hash256 = (hex) => {
if (typeof hex !== 'string') throw new Error('reverseHex expects a string')
if (hex.length % 2 !== 0) throw new Error(`Incorrect Length: ${hex}`)
let hexEncoded = hexEncoding.parse(hex)
let ProgramSha256 = SHA256(hexEncoded)
return SHA256(ProgramSha256).toString()
}
function hash256(hex) {
if (typeof hex !== 'string') throw new Error('reverseHex expects a string');
if (hex.
length % 2 !== 0) throw new Error('Incorrect Length:');
var hexEncoded = hexEncoding.parse(hex);
var ProgramSha256 = SHA256(hexEncoded);
return SHA256(ProgramSha256).toString()
}
function createCosmosAddress(publicKey) {
const message = CryptoJS.enc.Hex.parse(publicKey.toString(`hex`))
const hash = ripemd160(sha256(message)).toString()
const address = Buffer.from(hash, `hex`)
const cosmosAddress = bech32ify(address, Meteor.settings.public.bech32PrefixAccAddr)
return cosmosAddress
}
const derived = Buffer.from(key).toString("hex");
const derived1 = derived.slice(0, 64);
const derived2 = derived.slice(64);
const ciphertext = {
ciphertext: enc.Hex.parse(encrypted),
salt: "",
iv: ""
};
const decrypted = AES.decrypt(
ciphertext,
enc.Hex.parse(derived2),
AES_OPTIONS
);
const privateKey = hexXor(decrypted.toString(), derived1);
const account = new Account(privateKey);
const newAddressHash = SHA256(SHA256(
enc.Latin1.parse(account.address)
) as any)
.toString()
.slice(0, 8);
if (addressHash !== newAddressHash) {
reject(new Error("Wrong password or scrypt parameters!"));
}
log.info(`Successfully decrypted ${encryptedKey}`);
resolve(account.WIF);
}
}
);
export const hash160 = (hex) => {
if (typeof hex !== 'string') throw new Error('reverseHex expects a string')
if (hex.length % 2 !== 0) throw new Error(`Incorrect Length: ${hex}`)
let hexEncoded = hexEncoding.parse(hex)
let ProgramSha256 = SHA256(hexEncoded)
return RIPEMD160(ProgramSha256).toString()
}