Thread: basic encryption

  1. #1

    Question basic encryption

    I made a new game but the save files are easily modified to lets say give you a tactical advantage

    does anyone know a good site on basic encryption

    noithing to fancy pls

    Thank You

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Code:
    void EncryptString(char* String)
    {
       int Length = strlen(String);
       for(int i=0; i<Length; i++)
       {
          String[i]++;
       }
    }
    
    void DecryptString(char* String)
    {
       int Length = strlen(String);
       for(int i=0; i<Length; i++)
       {
          String[i]--;
       }
    }
    Or you could save the data in binary (I guess you save it as text now). Add ios::binary to the flags when you open the file and use write/read to save/load the data.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    booyakasha
    Join Date
    Nov 2002
    Posts
    208
    You could use Huffman code to save the chars ( and then you would be saving file space too ).

    If you don't know about Huffman Code just google it.

  4. #4

    Talking

    thank very much it works great!!

  5. #5
    I am he who is the man! Stan100's Avatar
    Join Date
    Sep 2002
    Posts
    361

    to magos

    with your ios::binary, can you give an example?
    Stan The Man. Beatles fan

    When I was a child,
    I spoke as a child,
    I thought as a child,
    I reasoned as a child.
    When I became a man,
    I put childish ways behind me"
    (the holy bible, Paul, in his first letter to the Cor. 13:11)

  6. #6
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Re: to magos

    Originally posted by Stan100
    with your ios::binary, can you give an example?
    Code:
    int MyVar = 12345;
    
    ofstream WriteFile;
    WriteFile.open("MyFile.sav", ios::out | ios::binary);
    
    if(!WriteFile.fail())
    {
       WriteFile.write((char*)&MyVar, sizeof(int));
       WriteFile.close();
    }
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Advice on writing a basic encryption program?
    By osiris^ in forum C Programming
    Replies: 2
    Last Post: 09-10-2007, 02:02 PM
  2. Problem with basic encryption program.
    By mmongoose in forum C++ Programming
    Replies: 5
    Last Post: 08-27-2005, 04:41 AM
  3. Basic encryption program???
    By Finchie_88 in forum C++ Programming
    Replies: 14
    Last Post: 09-10-2004, 09:01 AM
  4. basic encryption theory
    By y0gur7 in forum C Programming
    Replies: 13
    Last Post: 06-30-2003, 07:48 PM