### Installing ipcrypt-js Library (Shell) Source: https://github.com/jedisct1/ipcrypt-js/blob/main/README.md Provides commands to install the `ipcrypt-js` library using popular JavaScript package managers, npm and Bun. Requires a Node.js or Bun environment with the respective package manager installed. ```sh # Using npm (Node.js) npm install ipcrypt # Using Bun bun add ipcrypt ``` -------------------------------- ### Implementing Deterministic Encryption (JavaScript) Source: https://github.com/jedisct1/ipcrypt-js/blob/main/README.md Shows how to use the `deterministic` module from `ipcrypt` to encrypt and decrypt an IP address. Requires importing the module, generating a 16-byte key, and using the `encrypt` and `decrypt` functions. ```javascript import { deterministic } from 'ipcrypt'; // Create a 16-byte key const key = new Uint8Array(16); crypto.getRandomValues(key); // Encrypt an IP address const encrypted = deterministic.encrypt('192.168.1.1', key); console.log(encrypted); // Encrypted IP address // Decrypt the IP address const decrypted = deterministic.decrypt(encrypted, key); console.log(decrypted); // '192.168.1.1' ``` -------------------------------- ### Using IP Conversion Utility Functions (JavaScript) Source: https://github.com/jedisct1/ipcrypt-js/blob/main/README.md Shows how to use the `utils` module to convert IP address strings to byte arrays (`Uint8Array`) and vice-versa. Requires importing the `utils` module from the library. ```javascript import { utils } from 'ipcrypt'; // Convert IP address to bytes const bytes = utils.ipToBytes('192.168.1.1'); console.log(bytes); // Uint8Array // Convert bytes back to IP address const ip = utils.bytesToIp(bytes); console.log(ip); // '192.168.1.1' ``` -------------------------------- ### Implementing Non-Deterministic Encryption (JavaScript) Source: https://github.com/jedisct1/ipcrypt-js/blob/main/README.md Demonstrates using the `nonDeterministic` module for encryption and decryption. Requires importing the module, generating a 16-byte key and an 8-byte tweak, and using the `encrypt` and `decrypt` methods. ```javascript import { nonDeterministic } from 'ipcrypt'; // Create a 16-byte key and 8-byte tweak const key = new Uint8Array(16); const tweak = new Uint8Array(8); crypto.getRandomValues(key); crypto.getRandomValues(tweak); // Encrypt an IP address const encrypted = nonDeterministic.encrypt('192.168.1.1', key, tweak); console.log(encrypted); // Uint8Array containing encrypted data // Decrypt the IP address const decrypted = nonDeterministic.decrypt(encrypted, key); console.log(decrypted); // '192.168.1.1' ``` -------------------------------- ### Implementing Extended Non-Deterministic Encryption (JavaScript) Source: https://github.com/jedisct1/ipcrypt-js/blob/main/README.md Illustrates the usage of the `nonDeterministicExtended` module for encryption and decryption with larger keys and tweaks. Requires importing the module and generating 32-byte key and 16-byte tweak values. ```javascript import { nonDeterministicExtended } from 'ipcrypt'; // Create a 32-byte key and 16-byte tweak const key = new Uint8Array(32); const tweak = new Uint8Array(16); crypto.getRandomValues(key); crypto.getRandomValues(tweak); // Encrypt an IP address const encrypted = nonDeterministicExtended.encrypt('192.168.1.1', key, tweak); console.log(encrypted); // Uint8Array containing encrypted data // Decrypt the IP address const decrypted = nonDeterministicExtended.decrypt(encrypted, key); console.log(decrypted); // '192.168.1.1' ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.