C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 03-14-2006, 06:48 PM   #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
00Sven is offline   Reply With Quote
Old 03-14-2006, 07:47 PM   #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)
MadCow257 is offline   Reply With Quote
Old 03-14-2006, 08:36 PM   #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'
}
?????
00Sven is offline   Reply With Quote
Old 03-14-2006, 08:46 PM   #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.
MadCow257 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
creating very simple text editor using c if13121 C Programming 6 11-25-2004 09:49 AM
Simple message encryption Vicious C++ Programming 10 11-07-2004 11:48 PM
Binary Search Trees Part III Prelude A Brief History of Cprogramming.com 16 10-02-2004 03:00 PM
Simple simple program Ryback C++ Programming 10 09-09-2004 05:48 AM
Need help with simple DAQ program canada-paul C++ Programming 12 03-15-2002 08:52 AM


All times are GMT -6. The time now is 01:10 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22