Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Decrypt Function Fails Due to Incorrect Parameter Passing #120

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

VinaySatrasala
Copy link
Contributor

I raised and issue ragarding this so i am giving a pull request and please add labels to issue i am part of Gssoc

Bug: Decrypt Function Fails Due to Incorrect Parameter Passing

Description:

This PR addresses a bug in the decryption process of the password management application. The issue occurs in the decrypt function, where the input is not handled correctly, resulting in a TypeError when attempting to split the input string.

Issue:

  • Error Message: TypeError: text.split is not a function or its return value is not iterable
  • This error arises because the input to the decrypt function is incorrectly passed as an object instead of a string.

Changes Made:

  1. Fixed the decrypt Function:
    • Updated the implementation to accept a single string input rather than an object.
    • Adjusted the code that calls the decrypt function to ensure the correct value is passed.

Code Changes:

Here are the relevant sections of code for reference:

Original decrypt Function:

const decrypt = (text) => {
  const [iv, encryptedData] = text.split(":");
  const ivBuffer = Buffer.from(iv, "hex");

  const decipher = crypto.createDecipheriv(
    "aes-256-cbc",
    Buffer.from(ENCRYPTION_KEY),
    ivBuffer
  );
  let decrypted = decipher.update(encryptedData, "hex", "utf-8");

  decrypted += decipher.final("utf-8");

  return decrypted;
};

Updated Usage in the Password Fetching Route:

const decryptedPassword = passwords.map((item) => {
  const [iv, encryptedData] = item.password.split(':');
  return { ...item, password: decrypt(item.password) }; // Corrected the function call
});

Testing:

  • The application has been tested locally, and the bug has been resolved.
  • All existing functionality works as expected after the changes.

Conclusion:

This fix ensures that the decryption process functions correctly and enhances the stability of the application.


Feel free to modify any part of this template to better suit your style or to include any additional information you think might be relevant.

@sudo-dpkg sudo-dpkg added level1 gssoc: level 1 and removed level2 gssoc: level 2 labels Oct 29, 2024
@sudo-dpkg sudo-dpkg merged commit e31b008 into sudo-dpkg:main Oct 29, 2024
1 of 2 checks passed
@VinaySatrasala VinaySatrasala deleted the bug branch November 5, 2024 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gssoc-ext GSSoC'24 Extended hacktoberfest-accepted hacktoberfest 2024 level1 gssoc: level 1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants