Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

encryptionpackage

Package Overview
Dependencies
Maintainers
0
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

encryptionpackage - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

20

encryption.js
// encryption.js
// Helper function to derive a key from a passphrase
async function deriveKey(passphrase, salt) {
async function deriveKey(passphrase) {
const encoder = new TextEncoder();

@@ -14,7 +14,7 @@ const keyMaterial = await crypto.subtle.importKey(

// Derive a 256-bit AES key
// Derive a 256-bit AES key with appropriate usages
const key = await crypto.subtle.deriveKey(
{
name: 'PBKDF2',
salt: salt, // Use the provided salt for key derivation
salt: crypto.getRandomValues(new Uint8Array(16)), // Random salt for security
iterations: 100000,

@@ -24,5 +24,5 @@ hash: 'SHA-256'

keyMaterial,
{ name: 'AES-CBC', length: 256 },
true,
['encrypt', 'decrypt']
{ name: 'AES-CBC', length: 256 }, // Specify the key type and length
true, // The key is extractable
['encrypt', 'decrypt'] // Usages for the derived key
);

@@ -36,6 +36,4 @@

const encoder = new TextEncoder();
const salt = crypto.getRandomValues(new Uint8Array(16)); // Generate random salt
const cryptoKey = await deriveKey(passphrase); // Derive key from passphrase
const cryptoKey = await deriveKey(passphrase, salt); // Derive key from passphrase and salt
const iv = crypto.getRandomValues(new Uint8Array(16)); // Generate random IV

@@ -51,3 +49,2 @@

return {
salt: Array.from(salt), // Store the salt with the encrypted data
iv: Array.from(iv), // Convert to array for easy storage

@@ -61,4 +58,3 @@ content: Array.from(new Uint8Array(encrypted)) // Convert to array

const decoder = new TextDecoder();
const salt = new Uint8Array(encryptedData.salt); // Retrieve the salt
const cryptoKey = await deriveKey(passphrase, salt); // Derive key from passphrase and salt
const cryptoKey = await deriveKey(passphrase); // Derive key from passphrase

@@ -65,0 +61,0 @@ const iv = new Uint8Array(encryptedData.iv);

2

package.json
{
"name": "encryptionpackage",
"version": "1.0.3",
"version": "1.0.4",
"main": "encryption.js",

@@ -5,0 +5,0 @@ "module": "encryption.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc