Projects Inventory

Encryption/Decryption of Audio Files Gaming Project in C++

Explanation:

  1. XOR Cipher Function (xorCipher):
    • The xorCipher function performs encryption or decryption by applying an XOR operation with a single byte key. XOR is a symmetric operation, so it can be used for both encryption and decryption.
    • It iterates through each byte of the data and applies the XOR operation.
  2. File Reading (readFile):
    • The readFile function opens a binary file and reads its content into a vector<unsigned char>
      . This vector represents the raw binary data of the file.
    • It uses ios::ate to move to the end of the file and determine its size before reading the data into the buffer.
  3. File Writing (writeFile):
    • The writeFile function writes the contents of a vector<unsigned char> to a binary file. It takes the filename and the data to be written.
  4. Main Function (main):
    • The main function prompts the user to enter the input and output filenames, as well as the encryption/decryption key.
    • It reads the binary data from the input file, processes it using the XOR cipher, and writes the result to the output file.
    • The key must be in the range of 0-255 as it is a single byte used for the XOR operation.

Possible Enhancements:

Exit mobile version