Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function toChecksumAddress(address) {
address = address.toLowerCase().replace('0x', '')
let hash = createKeccakHash('keccak256')
.update(address)
.digest('hex')
let ret = '0x'
for (let i = 0; i < address.length; i++) {
if (parseInt(hash[i], 16) >= 8) {
ret += address[i].toUpperCase()
} else {
ret += address[i]
}
}
return ret
}
export const keccak256 = str =>
keccak('keccak256')
.update(str)
.digest();