Thread: Data Encryption Program

  1. #1
    Registered User
    Join Date
    Oct 2001

    Data Encryption Program

    I have two questions on this subject.

    1.) How would I (using the file manipulation commands (fstream)), do a search-and-replace for each possible letter and number in a file, and replace them with a random number from a key file?

    2.) Can fstream store each change that is has performed in a text file for the decryption process to use later?

    Thank you,
    -The Dragonlord

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Just print out a table onto the file or a seperate file. Then, when you want to decrypt, read the table from the file.

  3. #3
    Join Date
    Aug 2001
    Groningen (NL)
    You're implementing an encryption algorithm based on substitution isn't it?

    Since you know the maximum number of letters and numbers (and perhaps also other reading signs) in the file, you could also create a table before doing anything else.

    For example, there are 256 ASCII characters, so you could fill an array of 256 chars with random values. Then read the first character of the file, if this is for example 0xAB, then you could replace this character with element 0xAB of your array. Like this:

    current_character = key_array [0xAB];

    This way of encoding is faster than searching for characters in a file, since now you have to go through the file only once.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why does this program not work on my laptop?!
    By Eddie K in forum C Programming
    Replies: 1
    Last Post: 03-11-2006, 04:34 PM
  2. how do you make a program send data to the printer?
    By Sintu in forum C++ Programming
    Replies: 19
    Last Post: 10-20-2005, 07:22 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  5. HUGE fps jump
    By DavidP in forum Game Programming
    Replies: 23
    Last Post: 07-01-2004, 10:36 AM