{"library":"sjcl","title":"Stanford Javascript Crypto Library (SJCL)","description":"SJCL, or Stanford Javascript Crypto Library, is a high-level, open-source JavaScript cryptography library designed to provide secure and robust cryptographic primitives for web applications. While it was once a notable choice for client-side encryption, the library is officially deprecated by its maintainers. The current stable version is 1.0.9, but it has not seen significant feature development in many years, with recent updates primarily addressing critical vulnerabilities. Its release cadence is effectively stalled. Key differentiators at its prime included its focus on security best practices for in-browser cryptography and ease of use, but it is now advised against for new projects due to its age and the availability of more modern, actively maintained alternatives in the JavaScript crypto ecosystem.","language":"javascript","status":"deprecated","last_verified":"Sun Apr 19","install":{"commands":["npm install sjcl"],"cli":null},"imports":["const sjcl = require('sjcl');","const sjcl = require('sjcl');\nconst aes = sjcl.cipher.aes;","const sjcl = require('sjcl');\nconst sha256 = sjcl.hash.sha256;"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const sjcl = require('sjcl');\n\n// Generate a random key\nconst password = 'mySecretPassword';\nconst key = sjcl.misc.stringToBits(password);\n\n// Data to encrypt\nconst plaintext = 'Hello, secure world!';\n\n// Encrypt the data\nconst encrypted = sjcl.json.encrypt(key, plaintext);\n\nconsole.log('Encrypted data:', encrypted);\n\n// Decrypt the data\ntry {\n  const decrypted = sjcl.json.decrypt(key, encrypted);\n  console.log('Decrypted data:', decrypted);\n} catch (e) {\n  console.error('Decryption failed:', e.message);\n}\n\n// Example of hashing\nconst dataToHash = 'This is a test string for hashing.';\nconst hashBits = sjcl.hash.sha256.hash(dataToHash);\nconst hashHex = sjcl.codec.hex.fromBits(hashBits);\n\nconsole.log('SHA-256 hash:', hashHex);","lang":"javascript","description":"Demonstrates basic encryption and decryption using AES in GCM mode and SHA-256 hashing. It shows how to use the 'sjcl' object for core cryptographic operations.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}