verae-activate/creates/sha256.js

36 lines
1,017 B
JavaScript

/**
* SHA256 of a string — local, no API. Lets you hash a file/text in a Zap.
* @module creates/sha256
*/
const { createHash } = require('node:crypto');
const perform = async (_z, bundle) => {
const text = String(bundle.inputData.text ?? '');
const sha256 = createHash('sha256').update(text, 'utf8').digest('hex');
return { textLength: text.length, sha256, mode: 'local' };
};
module.exports = {
key: 'sha256_hash',
noun: 'Hash',
display: {
label: 'SHA256 Hash Text',
description: 'Computes SHA256 hex of text inside Zapier. No Verae call.',
},
operation: {
cleanInputData: false,
inputFields: [{ key: 'text', label: 'Text', type: 'text', required: true }],
perform,
sample: {
textLength: 5,
sha256: '2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824',
mode: 'local',
},
outputFields: [
{ key: 'sha256', type: 'string' },
{ key: 'textLength', type: 'integer' },
{ key: 'mode', type: 'string' },
],
},
};