1. ## 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 ?

2. >>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. Why arn't all posts which contain the words "homework" or "assignment", automaticly deleted? Good idea?

4. ## 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

5. 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. 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.

7. 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];

}```