Skip to content

Panda-Organization/PandaCipher

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PandaCipher



Introduction:

This program is a CLI application.

It allows to encrypt/decrypt a string/file using its own cipher method defined by: XORing, Substitutions and Permutations.

The avaible encryption modes are as follow:

  • CBC

In bonus.h, a function named getBestSBox(...) is defined but not used in the whole program. This function allow you to search in 210 tries

int * getBestSBox(int nbBits)
{
    DiffTable * diffTable = newDiffTable(nbBits);
    int size = diffTable->nbElts;

    int * sBox = malloc(size * sizeof(int));
    randomSBox(sBox, diffTable->nbBits);

    int * bestSBox = malloc(size * sizeof(int));
        
    initDiffTable(diffTable, sBox);
    int max = diffTable->max;
    int nbMax = -1;

    for (int i = 0; i < 1 << 10; ++i)
    {
        memcpy(bestSBox, sBox, size * sizeof(int));
        littleShuffle(bestSBox, size, 0.50);

        initDiffTable(diffTable, bestSBox);
        int n = numberOfMax(bestSBox, size, diffTable->max);
        if (max > diffTable->max || 
           (max == diffTable->max && (nbMax == -1 || nbMax > n)))
        {
            max = diffTable->max;
            nbMax = n;
            memcpy(sBox, bestSBox, size * sizeof(int));
        }
    }
    free(bestSBox);

    initDiffTable(diffTable, sBox);
    printf("Max in DiffTable: %d\n", diffTable->max);
    printf("Number of max: %d\n", nbMax);
    return sBox;
}

It's written in C programming language including some libraries like so:


Usage:

❯ ./pandaCipher --help
Usage: pandaCipher [OPTION...] ...args
PandaCipher - Symetrical encryption/decryption program
(https://github.com/MrrRaph/PandaCipher)

  -d, --decrypt[=DIGEST]
                             Specify decrypt mode
  -e, --encrypt[=STR]   Specify encrypt mode
  -i, --input-file=FILE Input file to be encrypted/decrypted
  -k, --cipher-key=KEY  Key for crypting
      --list-modes           Print cryptographic modes that can be
                             used
  -m, --encrypt-mode=MODE   Mode to use/used in the encryption.
                             Specify the number of the mode that you can see by
                             using --list-modes command (Default: 0, CBC)
  -?, --help                 Give this help list
      --usage                Give a short usage message
  -V, --version              Print program version

Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.

Report bugs to <dray@et.esiea.fr>|<samenaire@et.esiea.fr>.

Example:

You can encrypt/decrypt strings/files (with -i) on the command line. When encrypt/decrypt the program return the hex digest in case of non printable string when decrypting. Then you could use for example xxd with "-r -p" to convert hex string to string and recover the message.

❯ ./pandaCipher -e"Les Panda c'est la vie" -k "Pandanimal"
AA2D3C4CBC6D5E0C43ACC93AA22146DB47F54A9F9DE07175D3A2D92B8E898BE8
❯ ./pandaCipher -d"AA2D3C4CBC6D5E0C43ACC93AA22146DB47F54A9F9DE07175D3A2D92B8E898BE8" -k "Pandanimal"
4C65732050616E6461206327657374206C612076696500000000000000000000
❯ ./pandaCipher -d"AA2D3C4CBC6D5E0C43ACC93AA22146DB47F54A9F9DE07175D3A2D92B8E898BE8" -k "Pandanimal" | xxd -r -p
Les Panda c'est la vie%                                                       

About

Symetrical encryption/decryption program

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 99.7%
  • Makefile 0.3%