declare let Uint8Array ; param buffer export function hexString ( buffer ) { const byteArray = new Uint8Array ( buffer ) ; const hexCodes = [ ... byteArray ] . map ( ( value ) => { const hexCode = value . toString ( 16 ) ; const paddedHexCode = hexCode . padStart ( 2 , '0' ) ; return paddedHexCode ; } ) ; return hexCodes . join ( '' ) ; } param message export function digestMessage ( message ) { const encoder = new TextEncoder ( ) ; const data = encoder . encode ( message ) ; return window . crypto . subtle . digest ( 'SHA-256' , data ) ; } param message export async function digest ( message ) { const arrayBuffer = await digestMessage ( message ) ; const hex = hexString ( arrayBuffer ) ; return hex ; } param message export async function isEven ( message ) { const arrayBuffer = await digestMessage ( message ) ; const byteArray = new Uint8Array ( arrayBuffer ) ; return ( byteArray . reduce ( ( previousValue , currentValue ) => previousValue + currentValue ) % 2 === 0 ) ; }