Coder Social home page Coder Social logo

pandacipher's Introduction

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 <[email protected]>|<[email protected]>.

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%                                                       

pandacipher's People

Contributors

mrrraph avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.