Thread: Encryption/decryption algorithm

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    28

    Question Encryption/decryption algorithm

    Hi everyone,

    I have bee asked in an assignment to implement (S-P) Network program which is an encryption/decryption prorgram. the program encodes 4 letter words, it has initial permutation function that swaps two of the messages...and there is an S-box that perform substitution, the number of keys to use are two.

    Can anyone suggest how I can get started to implement
    this algorithm ?

    thanks in advance.

  2. #2
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    >>I have bee asked in an assignment ...

    We do not do your work for you. Start some code yourself, and when you cannot go any further, come to us for help.

  3. #3
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    Why arn't all posts which contain the words "homework" or "assignment", automaticly deleted? Good idea?

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    249

    That is because .. We are students...

    We don't get paid for this work... So we just need it for our homeworks....

    When any student ask for a help... s/he will be asking for a hints ... not for all the solution..

    We - as a students - just tell the truth ,,, We are doing our homework and we need help....


    Thnx
    C++
    The best

  5. #5
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    Originally posted by face_master
    Why arn't all posts which contain the words "homework" or "assignment", automaticly deleted? Good idea?
    because posts like your own would also be automaticly deleted

  6. #6
    Registered User toaster's Avatar
    Join Date
    Apr 2002
    Posts
    161
    Abdi, can you be more specific as to how the program should work?

    so far, the main point I consider in this program is to encrypt a 4 character string array using some permutation method. maybe you can provide a little more info on this topic.
    think only with code.
    write only with source.

  7. #7
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    You could create two functions, one for the P-box and one for the S-box. Then pass the string first to the P-box and then to the S-box for encoding.

    For the decoding you need to write functions for inverse P-box and inverse S-box. First you send the encrypted string to the inverse S-box and then to the inverse P-box.

    An S-box could be implemented like this:

    Code:
    char original_str [4];
    char s_box_str [4];
    int index;
    
    for (index = 0; index < 4; index++)
    {
        switch (original_str [index])
        {
            case 'a':
                s_box_str [index] = 'd';
                break;
            case 'b':
                s_box_str [index] = 'p';
            etc.
        }
    }
    And a P-box could look like something like this:

    Code:
    char original_str [4];
    char p_box_str [4];
    
    p_box_str [0] = original_str [1];
    p_box_str [1] = original_str [3];
    p_box_str [2] = original_str [2];
    p_box_str [3] = original_str [0];
    
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Implement of a Fast Time Series Evaluation Algorithm
    By BiGreat in forum C Programming
    Replies: 7
    Last Post: 12-04-2007, 02:30 AM
  2. Replies: 4
    Last Post: 12-10-2006, 07:08 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. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM