Skip to content

Commit

Permalink
use toHex instead of Buffer.from in generateHash
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniSomoza committed Nov 28, 2024
1 parent 642ccf5 commit 851e75e
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { keccak256, toHex } from 'viem'
* @returns {string} A hexadecimal string representation of the truncated hash, without the `0x` prefix.
*/
export function generateHash(input: string, size: number): string {
const fullHash = keccak256(Buffer.from(input))
const fullHash = keccak256(toHex(input))
return toHex(fullHash.slice(-size)).replace('0x', '') // Take the last X bytes
}

Expand Down

0 comments on commit 851e75e

Please sign in to comment.