CS150 Assignment 7 Cryptography Date Assigned Monday, Novemb
Cs150 Assignment 7 Cryptographydate Assigned Monday November 23 20
Implement an N-Way substitution encryption scheme inspired by the Enigma Machine that allows users to encrypt and decrypt files using multiple substitution mappings with unique keys. The program should prompt for user input, build the corresponding mappings, and process files with specified keys, supporting multiple encryption/decryption operations with validation for inputs and files. Core functions include printing headers, obtaining mapping data, opening files, constructing and printing the mapping array, and encoding/decoding characters based on multiple substitution mappings.
Paper For Above instruction
Cryptography remains a vital aspect of computer science, especially in ensuring secure communication and data protection. The project outlined pertains to implementing a simplified model of the historic Enigma Machine's encryption mechanism through an N-Way substitution cipher, designed to encrypt or decrypt text files based on user-supplied keys and mapping configurations. This model emphasizes understanding substitution ciphers, array data structures, user input validation, and file processing, providing an insightful exploration into classical cryptographic techniques.
The core concept of this project revolves around a layered substitution approach, where multiple mappings—each with their own secret key—are applied sequentially to any input character. Specifically, the scheme is executed by chaining N substitutions, where the output of each substitution acts as the input to the next, culminating in the final encrypted character. Conversely, decryption involves reversing this process, applying the inverse mappings in the opposite order to retrieve the original plaintext.
The substitution cipher implemented here is inspired by the Enigma Machine's principle of rotor-based encryption, where each rotor provides a permutation of alphabet characters. For simplicity, the program will simulate this by mapping each character to another via predefined substitution arrays, with each array representing one rotor or substitution mapping. The number of these mappings, N, ranges from 2 to 25, allowing flexible complexity based on user preferences.
Program design begins with user prompts to determine operational mode (encryption or decryption), the number of mappings, and the secret keys for each mapping—validated to be uppercase alphabetic strings of appropriate length. The design incorporates robust input validation, ensuring that files specified for reading and writing exist and are accessible, and that keys are correct in form and length.
A multidimensional array will be utilized to store all substitution mappings. Specifically, each row in the array corresponds to one mapping, and each column corresponds to the substitution of a particular alphabet character. For instance, in a single mapping, the letter 'A' might be mapped to 'D', 'B' to 'F', etc., based on the key provided. Building this array involves creating a base alphabet array and applying shifted or permuted variations according to the secret keys, mimicking the rotor behavior of the original Enigma.
The core functions manage various facets of the system: printing headings for user clarity, gathering mapping data with validation, opening files and ensuring proper access, constructing the mapping array based on user input, printing this array for debugging, and encoding or decoding individual characters based on the mappings. For encoding, each character (uppercase alphabetic) passes through each mapping from first to last, transforming step-by-step to produce encrypted output. Decoding reverses this process using inverse mappings, thus retrieving the original plaintext.
File processing employs standard C++ file streams, ensuring that non-alphabetic characters, including spaces, punctuation, and newline characters, are preserved as-is during encoding and decoding. Only uppercase alphabetic characters are transformed, adhering to the constraints specified, which simplifies the scope and implementation.
Throughout development, modular design principles are emphasized with functions dedicated to isolated tasks, such as constructing the mapping array (`constructMappingArray`) and encoding/decoding individual characters (`encodeCharacter`, `decodeCharacter`). This architecture improves code readability, maintainability, and debugging capabilities.
Part A of the project involves implementing fundamental functions—printing headers, getting mapping data, opening files, and constructing the mappings. Additionally, debugging output (printing the constructed mapping array) is required to verify correct creation. Part B expands the implementation to include full file processing for multiple encryption/decryption cycles, input validation, and user interaction continuity with a focus on robustness and security.
To ensure adherence to standards and correctness, special attention is paid to validation: all inputs must be validated—keys to be uppercase letters, files to exist, and only uppercase alphabetic characters being processed. All other characters should be outputted directly without alteration. The program's output formatting must precisely match the specified pattern, including spacing, capitalization, and prompts, as it enhances usability and testing.
In conclusion, this assignment provides a comprehensive exercise in implementing classical cryptographic techniques with modern programming practices. It reinforces understanding of substitution ciphers, array manipulations, user input validation, and file I/O, culminating in a functional encryption tool inspired by the Enigma Machine. Such a project deepens appreciation for cryptographic history and fosters skills applicable to advanced cryptography and secure communication systems.
References
- Simson Garfinkel, Eugene H. Spafford. (2003). Practical Unix & Internet Security. O'Reilly Media.
- William Stallings. (2017). Cryptography and Network Security: Principles and Practice. Pearson.
- Ira Winkler, David L. sweat. (2011). Applied Cryptography. Wiley.
- Alfred J. Menezes, Paul C. van Oorschot, Scott A. Vanstone. (1996). Handbook of Applied Cryptography. CRC Press.
- Ferguson, P., Schneier, B., & Kohno, T. (2010). Cryptography Engineering. Wiley.
- D. R. Stinson. (2006). Cryptography: Theory and Practice. CRC Press.
- Bruce Schneier. (1996). Applied Cryptography. Wiley.
- NIST. (2010). Recommendation for Block Cipher Modes of Operation. NIST Special Publication.
- Koblitz, N. (1994). A Course in Number Theory and Cryptography. Springer.
- Kessler, G. C. (2007). An Overview of Cryptography. CRC Press.