New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.2 to 1.0.3

12

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

@@ -18,3 +18,3 @@ const keyMaterial = await crypto.subtle.importKey(

name: 'PBKDF2',
salt: crypto.getRandomValues(new Uint8Array(16)), // Random salt for security
salt: salt, // Use the provided salt for key derivation
iterations: 100000,

@@ -35,4 +35,6 @@ hash: 'SHA-256'

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

@@ -48,2 +50,3 @@

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

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

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

@@ -60,0 +64,0 @@ const iv = new Uint8Array(encryptedData.iv);

{
"name": "encryptionpackage",
"version": "1.0.2",
"version": "1.0.3",
"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