Crypto Tools: SHA

This flow implements capabilities for hashing user provided data using Secure Hash Algorithm.

[{"id":"86c9cf7c4c6709b8","type":"subflow","name":"SHA","info":"This subflow implements capabilities for hashing user provided data using *Secure Hash Algorithm*.The subflow supports the following versions of **SHA**:\n\n- SHA1 = \"1\"\n- SHA224 = \"224\"\n- SHA256 = \"256\"\n- SHA384 = \"384\"\n- SHA512 = \"512\"\n- SHA3 = \"3\"\n\n## *Hashing*\n### Inputs\n>\n> **payload.*version***: SHA version to use. (Optional)\n>\n> **payload.*data***: User data to hash.\n>\n\n### Outputs\n>\n> **payload.*algo***: Algorithm used for hashing.\n>\n> **payload.*hash***: Hash of the provided data.\n>\n","category":"CryptoRed","in":[{"x":60,"y":80,"wires":[{"id":"ea6d34cdbe6f1d9f"}]}],"out":[{"x":550,"y":80,"wires":[{"id":"ea6d34cdbe6f1d9f","port":0}]}],"env":[{"name":"version","type":"str","value":"256","ui":{"icon":"font-awesome/fa-cog","label":{"en-US":"Version"},"type":"select","opts":{"opts":[{"l":{"en-US":"SHA1"},"v":"1"},{"l":{"en-US":"SHA224"},"v":"224"},{"l":{"en-US":"SHA256"},"v":"256"},{"l":{"en-US":"SHA384"},"v":"384"},{"l":{"en-US":"SHA512"},"v":"512"},{"l":{"en-US":"SHA3"},"v":"3"}]}}}],"meta":{"module":"node-red-contrib-crypto-tools-sha","version":"0.0.1","author":"Thodoris Ioannidis <[email protected]>","desc":"Secure Hash Algorihm functionalities","keywords":"SHA, hashing","license":"Apache-2.0"},"color":"#3FADB5","inputLabels":["message"],"outputLabels":["hash"],"icon":"font-awesome/fa-lock"},{"id":"ea6d34cdbe6f1d9f","type":"function","z":"86c9cf7c4c6709b8","name":"Secure Hash Algorithm","func":"function hash1(data){\n    return cryptoJs.SHA1(JSON.stringify(data)).toString();\n}\nfunction hash224(data){\n    return cryptoJs.SHA224(JSON.stringify(data)).toString();\n}\nfunction hash256(data){\n    return cryptoJs.SHA256(JSON.stringify(data)).toString();\n}\nfunction hash384(data){\n    return cryptoJs.SHA384(JSON.stringify(data)).toString();\n}\nfunction hash512(data){\n    return cryptoJs.SHA512(JSON.stringify(data)).toString();\n}\nfunction hash3(data){\n    return cryptoJs.SHA3(JSON.stringify(data)).toString();\n}\ndata = msg.payload.data\nlet hash, algo, version = msg.payload.version || env.get('version');\nswitch(version){\n    case \"1\":\n        algo = \"SHA1\"\n        hash = hash1(data)\n        break;\n    case \"224\":\n        algo = \"SHA224\"\n        hash = hash224(data)\n        break;\n    case \"256\":\n        algo = \"SHA256\"\n        hash = hash256(data)\n        break;\n    case \"384\":\n        algo = \"SHA384\"\n        hash = hash384(data)\n        break;\n    case \"512\":\n        algo = \"SHA512\"\n        hash = hash512(data)\n        break;\n    case \"3\":\n        algo = \"SHA3\"\n        hash = hash3(data)\n        break;\n}\n\nmsg.payload = {\n    algo: algo,\n    hash: hash\n} \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"cryptoJs","module":"crypto-js"}],"x":300,"y":80,"wires":[[]]}]

Flow Info

Created 2 years, 5 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • function (x1)
Other
  • subflow (x1)

Tags

  • sha
  • hashing
  • integrity
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option