Skip to content
New issue

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

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

Already on GitHub? # to your account

Create vigenere.js #1982

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

VICKY15032008
Copy link

Vigenère Cipher with Input Cleaning and Combined Alphabet

The script that implements a secure Vigenère cipher. The cipher is designed to work on a combined alphabet of lowercase letters and digits, while ensuring the input is clean by removing spaces and any non-alphanumeric characters.

Features and Benefits

  • Input Cleaning

    • Space Removal: All spaces are removed from the input text.
    • Special Character Detection: Uses a regular expression to detect and remove any characters that are not letters or digits.
    • Error Handling: Raises an error if any forbidden characters are present, ensuring that only valid, alphanumeric text is processed.
    • Benefit: Guarantees data integrity before encryption by strictly sanitizing the input.
  • Modified Vigenère Cipher

    • Combined Alphabet: Utilizes a custom alphabet consisting of abcdefghijklmnopqrstuvwxyz0123456789 (36 characters total).
    • Encryption Process:
      • Converts both the message and key to lowercase.
      • For each character in the cleaned message, the script finds its index in the combined alphabet.
      • A corresponding key character is used (cycled as needed) to determine a shift value.
      • The new character is computed using modulo arithmetic.
    • Decryption Process:
      • Reverses the encryption by subtracting the shift value for each character.
      • Recovers the original message from the encrypted text.
    • Benefit: Supports both letters and digits, making the cipher more versatile for a variety of alphanumeric messages.
  • Robust Error Handling

    • All major functions (cleaning, encryption, and decryption) are wrapped in try/except blocks.
    • Provides clear error messages in case of invalid input or unexpected errors during processing.
    • Benefit: Ensures the program fails gracefully and informs the user of any issues.
  • User Interaction

    • The main() function prompts the user for a message and key.
    • It displays the cleaned input, the encrypted message, and the decrypted message.
    • Benefit: Offers an easy-to-use interface to test and interact with the cipher.

in these peice of code you can use it for the alphabets and including numbers and removing out all the traces of punctuation marks and special characters and making it easy to work with and along side these code has both the encryption and decryption codes
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in these peice of code you can use it for the alphabets and including numbers and removing out all the traces of punctuation marks and special characters and making it easy to work with and along side these code has both the encryption and decryption codes

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant