Get started with crypto-js CDN

MIT licensed

Crypto-JS is a popular open-source library for cryptographic functions in JS.

Tags:
  • security
  • crypto
  • Hash
  • MD5
  • SHA1
  • SHA-1
  • SHA256
  • SHA-256
  • RC4
  • Rabbit
  • AES
  • DES
  • PBKDF2
  • HMAC
  • OFB
  • CFB
  • CTR
  • CBC
  • Base64

Stable version

Copied!

How to start using crypto-js CDN


<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.cdnhub.io/crypto-js/4.2.0/crypto-js.min.js"></script>
  <title>Get started with crypto-js CDN - cdnhub.io</title>
</head>
<body>
  <button id="encrypt">Encrypt</button>
  <button id="decrypt">Decrypt</button>
  <input type="text" id="inputText" value="Some text to encrypt">
  <p id="output"></p>

  <script>
    const inputText = document.getElementById('inputText');
    const output = document.getElementById('output');
    const encryptButton = document.getElementById('encrypt');
    const decryptButton = document.getElementById('decrypt');

    encryptButton.addEventListener('click', () => {
      const textToEncrypt = inputText.value;
      const key = CryptoJS.lib.WordArray.create(['0123456789abcdef']); // You can use a custom key
      const encrypted = CryptoJS.SHA256(textToEncrypt).toString();
      output.textContent = 'Encrypted text: ' + encrypted;
    });

    decryptButton.addEventListener('click', () => {
      const textToDecrypt = inputText.value;
      const key = CryptoJS.lib.WordArray.create(['0123456789abcdef']); // Use the same key as during encryption
      const decrypted = CryptoJS.SHA256.parse(textToDecrypt).toString(CryptoJS.enc.Hex);
      output.textContent = 'Decrypted text: ' + decrypted;
    });
  </script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions