Download spectrum/shared/encryption/index.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 881 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/shared/encryption/index.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/shared/encryption/index.js
-
curl -L -o index.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/shared/encryption/index.js
881 Bytes
| // @flow | |
| require('now-env'); | |
| var ENCRYPTION_KEY = | |
| process.env.NODE_ENV === 'development' | |
| ? 'abcdefghijklmnopqrstuvwxyzasdfjk' | |
| : process.env.ENCRYPTION_KEY; // Must be 256 bytes (32 characters) | |
| if (!ENCRYPTION_KEY) { | |
| throw new Error( | |
| 'Looks like youre missing an encryption key for sensitive data!' | |
| ); | |
| } | |
| var Cryptr = require('cryptr'), | |
| cryptr = new Cryptr(ENCRYPTION_KEY); | |
| function encryptString(text /*: string */) /*: string */ { | |
| return cryptr.encrypt(text); | |
| } | |
| function decryptString(text /*: string */) /*: string */ { | |
| return cryptr.decrypt(text); | |
| } | |
| function encryptObject(object /*: Object */) /*: Object */ { | |
| return cryptr.encrypt(JSON.stringify(object)); | |
| } | |
| function decryptObject(text /*: string */) /*: Object */ { | |
| return JSON.parse(cryptr.decrypt(text)); | |
| } | |
| module.exports = { decryptString, encryptString, decryptObject, encryptObject }; | |