Thread: Simple Filter

  1. #1
    Registered User 00Sven's Avatar
    Join Date
    Feb 2006
    Posts
    127

    Simple Filter

    I was wondering if there was a way to make a simple filter (other than ROT13) for passwords so that I can put it through the filter and then save it into a text file so that it is there but not directly. I would need to make one function to filter and then another to un-filter. I just don't know where to start.
    ~Sven

  2. #2
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    Table based comes to mind
    That would be where you have a static table known only to the encoder and decoder which modifies the stream. Another idea is XOR (there's a faq)

  3. #3
    Registered User 00Sven's Avatar
    Join Date
    Feb 2006
    Posts
    127
    So I just make a section with a bunch of statements like...
    Code:
    if(toupper(c)=='A'){
         c='R';
    }
    and then in the decoder have it be...
    Code:
    if(toupper(c)=='R'){
         c='a'
    }
    ?????

  4. #4
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    Here's an example

    Code:
    #include <stdio.h>
    
    int main()
    {
    	char table [] = "randomletters";
    	char input [] = "testinputchar";
    	char output [13];
    	unsigned int i;
    	for (i = 0; i < sizeof(input); i++)
    		output[i] = input[i] + table[i];
    	printf (output);
    }
    My code is simplified in 2 aspects. One, you would not statically allocate your output like I did, and the input and table will not be the same length. The solution is pretty easy to implement, just have an iterator that bounces back to the begining of the table once you reach the end.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. creating very simple text editor using c
    By if13121 in forum C Programming
    Replies: 9
    Last Post: 10-19-2010, 05:26 PM
  2. Simple message encryption
    By Vicious in forum C++ Programming
    Replies: 10
    Last Post: 11-07-2004, 11:48 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Simple simple program
    By Ryback in forum C++ Programming
    Replies: 10
    Last Post: 09-09-2004, 05:48 AM
  5. Need help with simple DAQ program
    By canada-paul in forum C++ Programming
    Replies: 12
    Last Post: 03-15-2002, 08:52 AM