Thread: Example to encrypt and decrypt files with permutated numbers

  1. #1
    Registered User
    Join Date
    Nov 2018
    Location
    Amberg in upper palatinate, Bavaria
    Posts
    49

    Example to encrypt and decrypt files with permutated numbers

    Here is a program were i wrote by my own with Qt for linux to encrypt and decrypt files.
    It based on transposition of bits. It splits a file into blocks of a length you can
    select between 64, 128, 256, 1024, 2048, 4096, 8192, 16384, 32768, 65536 and

    31072 bit length of the key.

    if you have 131072 bit length of the key the length of the block is 16284 Byte.
    First the program generates a array of numbers from 0 to 131071, every number is only one time in this array:
    Code:
    values: 0,1,2,3,4,5,6,7,8,9..............................131071
    unsigned int keycode[131072] = { 2,4,5,8,9,0,1,6,3,7,131071, 6532......1 } ;
    
    To encrypt the bits:
    
    for (a = 0; a <  131071; a++)
    gecodet[a] = array[ keycode [a] ];
    
    
    
    to decrypt:
    for (a = 0; a <=131071; a++)
    array[ keycode[a] ] = gecodet[a];
    see more in the source files.





    The second step is to permute this array.
    The possible number of different results are up to 131072 factorials.

    example:
    If you would have a file with exactly the same numer of bits were are set(1)
    and bits where are not set

    Bytes... Bits .......psssible number of permutations
    Nibbel........4............6
    1.............8............70
    2.............16...........12870
    4.............32...........6.0108E+8
    8.............64...........1.83262E+18
    16............128..........2.39511E+37
    32............256..........5.76866E+75
    64............512..........4.72553E+152
    128...........1024.........4.48125e+306
    256...........2048.........5.69709e+614
    512...........4096.........1.30195e+1231
    1024..........8192.........9.61516e+2436
    2048..........16384 .......7.41605e+4929
    4096..........32768........??????
    8192..........65536........?????? (about 45 seconds to generate key)
    18384.........131072.......??????(needs several time to generate key!!)



    Third step is to permute the bits of the block to encrypt himself.
    They will copy to an other place of a second array what will write into a encrypted file.
    But first the program will check how long your source file(to encrypt ) is and will change the size of it. The original length of the decrypted file will save at the length of the key-file.
    Sorry, some parts are written in german, but i still hope that any people can use it for to make a program where is okay.

    All source files are in the Attachments.
    The bin file to use with 825KiB was to great for a attachment here.

    but:
    NEVER WORK WITH TH ORIGINAL FILES: NEVER NEVER NEVER!
    Attached Files Attached Files

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [Help Me]Very Simply Encrypt/Decrypt
    By ShiroAzure in forum C++ Programming
    Replies: 11
    Last Post: 04-18-2011, 12:58 PM
  2. decrypt/encrypt
    By wonderpoop in forum C Programming
    Replies: 15
    Last Post: 10-18-2006, 06:10 PM
  3. Encrypt/Decrypt files by XOR
    By amirahasanen1 in forum C++ Programming
    Replies: 27
    Last Post: 05-22-2005, 02:38 PM
  4. Encrypt/Decrypt
    By bitWise in forum C Programming
    Replies: 2
    Last Post: 10-14-2001, 03:48 PM
  5. how to encrypt/decrypt
    By bitWise in forum C Programming
    Replies: 3
    Last Post: 10-13-2001, 01:02 PM

Tags for this Thread