basic encryption

This is a discussion on basic encryption within the C++ Programming forums, part of the General Programming Boards category; I made a new game but the save files are easily modified to lets say give you a tactical advantage ...

  1. #1
    Spanky devour89's Avatar
    Join Date
    Nov 2002
    Posts
    148

    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
    Spanky devour89's Avatar
    Join Date
    Nov 2002
    Posts
    148

    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, 03:02 PM
  2. Problem with basic encryption program.
    By mmongoose in forum C++ Programming
    Replies: 5
    Last Post: 08-27-2005, 05:41 AM
  3. Basic encryption program???
    By Finchie_88 in forum C++ Programming
    Replies: 14
    Last Post: 09-10-2004, 10:01 AM
  4. basic encryption theory
    By y0gur7 in forum C Programming
    Replies: 13
    Last Post: 06-30-2003, 08:48 PM

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