Skip to content

Commit

Permalink
Increased pbkdf2 iterations to 100000
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekY495 committed Nov 9, 2022
1 parent 2d5cb8f commit 7a1b54f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/backend/encryption.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { Buffer } = require("buffer");
const app = {
encrypt: function (data, password) {
const salt = nodeCrypto.randomBytes(16);
const key = nodeCrypto.pbkdf2Sync(password, salt, 5, 32, "sha256");
const key = nodeCrypto.pbkdf2Sync(password, salt, 100000, 32, "sha256");
const cipher = nodeCrypto.createCipheriv("aes-256-gcm", key, salt);
const encryptedData = Buffer.concat([cipher.update(data), cipher.final()]);
const authTag = cipher.getAuthTag();
Expand All @@ -15,7 +15,7 @@ const app = {
const salt = data.subarray(0, 16);
const authTag = data.subarray(16, 32);
const encData = data.subarray(32, data.length);
const key = nodeCrypto.pbkdf2Sync(password, salt, 5, 32, "sha256");
const key = nodeCrypto.pbkdf2Sync(password, salt, 100000, 32, "sha256");
const decipher = nodeCrypto.createDecipheriv("aes-256-gcm", key, salt);
decipher.setAuthTag(authTag);
const plainText = Buffer.concat([
Expand Down

0 comments on commit 7a1b54f

Please sign in to comment.