Share feedback, ideas and get community help

Updated 11 months ago

sha1

Hi There,
Could you please let me know if there is any way to encode a “text” using sha1 for password? If you could send me an example to use it in the set variable. please
s
L
4 comments
Hi, try the next. Create a set var with this code and mark "execute on client option":

function u8ToHex (u8){
return u8.toString(16).padStart(2, '0');
}

const supportedAlgorithms = [
'SHA-1',
'SHA-256',
'SHA-384',
'SHA-512',
];

async function hexDigest (
algorithm,
message,
){
let buf;
if (typeof message === 'string') buf = new TextEncoder().encode(message);
else if (message instanceof Blob) buf = await message.arrayBuffer();
else buf = message;
const hash = await crypto.subtle.digest(algorithm, buf);
return [...new Uint8Array(hash)].map(u8ToHex).join('');
}
const rsha = await hexDigest('SHA-1','put your text or variable here')
return rsha
Other sample of sha-1 function created with chatgpt.
Dear All, I created an external API using NEXTJS to return encoded text and consume in the typebot. Why? Because the possible solutions were full compatible with some devices.
Add a reply
Sign up and join the conversation on Discord