Thread: Help with simple Arry encoder

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    118

    Help with simple Arry encoder

    I am triying to make a program which encodes a user password and writes it to a file this is what I have:
    Code:
    /*ENCODER*/
    void Encoder(char *Code) 
    {
    	for (int i = 0; i < strlen(Code); i++) 
    		Code[i] -= 30;               
    		
    	Code[i] = '\0'; 
    }
    Code:
    /*DECODER*/
    void Decoder(char *Code) 
    {
    	for (int i = 0; i < strlen(Code); i++) 
    		Code[i] += 30; 
    
    	Code[i] = '\0'; 
    }
    it works fine, but I want to do something better like
    Code:
    /*ENCODER*/
    void Encoder(char *Code) 
    {
    	for (int i = 0; i < strlen(Code); i++) 
    		Code[i] = (Code[i] * 100) % 256;               
    		
    	Code[i] = '\0'; 
    }
    The only problem with that is that I would have no idea how to decode it, could someone describe how the modulus works so I can find a way to decode the arry please?
    Why drink and drive when you can smoke and fly?

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    118
    Ok thanks, but is there any way to encode something like that other than doing what I did?
    Why drink and drive when you can smoke and fly?

  3. #3
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    XOR

    Bitwise exclusive-or seems to be a popular encyption method. It's reversable. You just exclusive-or with your "key".

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