Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Encrypting

Name: Anonymous 2010-10-04 0:20

What's your thoughts on encrypting multiplying characters four at a time by matrix then decrypting using A^(-1) as devision in the same fasion.

Obviously this is private key if the matrix is set up on opening of the program.

What you guys do? what next?

Name: Anonymous 2010-10-04 0:33

good old memfrob. (man memfrob)

Name: Anonymous 2010-10-04 7:05

>>1
Other than the obvious problem, the encryption algorithm is easy to break using basic linear algebra.  It's easy to attack.

Here's a known plaintext attack:

Let x1, x2, ..., xn be the plaintext grouped in units of four characters, so x1 is the first four characters, etc.  Each xi is a four dimensional column vector.  The key is a four by four matrix, M.  The cipher text is Mx1, Mx2, ..., Mxn.

Suppose that the attacker knows the values of x1...x4, and suppose that these are linearly independent.  The attacker creates a matrix X whose columns are x1...x4 (the known plaintext), and a matrix Y whose columns are Mx1...Mx4 (the ciphertext).  Using simple Gauss-Jordan elimination it is possible to solve the equation MX = Y for M in O(N^3) time.

In practice, a known plaintext attack is the death knell for any algorithm, and most sets of four four-dimensional vectors are linearly independent -- making this attack very easy.  Your encryption is easy to break, if it even works at all.

And that's a good question... does it work at all?

And the obvious problem: The answer is no!  Why?  Because your scalar field has to actually be a field in order to work.  That is, using the integers 0 to 255 (or -128 to 127) you will end up with an encryption function that is not injective, i.e., that when you decrypt it, you will get multiple possible answers.  However, the fix is easy.  Just pick a finite field with 256 elements in it and you're good.  (Of course, it's just as easy to crack.)

Name: OP 2010-10-04 14:41

>>3
hmm:

/*
needs
    - completing (full streaming sentences)
    - put in files[header/source]
    - done for more than four letters
*/

#include "stdafx.h"
#include "gwin.h"

#include <iostream>
#include <string>

using namespace std;
// global rules for matrixs
// MATRIX_name = [a,b,c,d]

class Criptic
{
public:
    double encoded[100];

    string Encrypt(string word);
    string Decrypt(string word);

    void SetCodes();

private:
   
    double ME[4];//MATRIX encoder
    double MEM1[4];//MATRIX encoder to the minus 1
    //  MATRIX[0,1,2,3]
    //  MATRIX[a,b,c,d]
};

void Criptic::SetCodes()
{
    ME[0] = 3.0;
    ME[1] = 3.0;
    ME[2] = 7.0;
    ME[3] = 5.0;

    MEM1[0] = (-(5.0/6.0));
    MEM1[1] = (1.0/2.0);
    MEM1[2] = (7.0/6.0);
    MEM1[3] = (-(1.0/2.0));
};

string Criptic::Encrypt(string word)
{
    string temp = "0000";
    int i = 0;
    int counter = 0;

    do       
    {
        if(counter == 3)
        {
            temp[counter] = word[i];
            counter = 0;

            double aM = (double) temp[0];
            double bM = (double) temp[1];
            double cM = (double) temp[2];
            double dM = (double) temp[3];
           
            encoded[i-3] = (aM*ME[0])+(bM*ME[2]);
            encoded[i-2] = (aM*ME[1])+(bM*ME[3]);
            encoded[i-1] = (cM*ME[0])+(dM*ME[2]);
            encoded[i] = (cM*ME[1])+(dM*ME[3]);


            word[i-3] = encoded[i-3];
            word[i-2] = encoded[i-2];
            word[i-1] = encoded[i-1];
            word[i] = encoded[i];

            ++i;
        }
       
        if(counter < 3)
        {
            temp[counter] = word[i];
        }

        ++counter;
        ++i;
    }while(i < word.size()); // word[i] != '\0'

    return word;
};

string Criptic::Decrypt(string word)
{
    double tempNUMS[4];
    int ii = 0;
    int counter = 0;

    do       
    {
        if(counter == 3)
        {
            tempNUMS[counter] = encoded[ii];
            counter = 0;

            double aM = (double) tempNUMS[0];
            double bM = (double) tempNUMS[1];
            double cM = (double) tempNUMS[2];
            double dM = (double) tempNUMS[3];

            word[ii-3] = (aM*MEM1[0])+(bM*MEM1[2]);
            word[ii-2] = (aM*MEM1[1])+(bM*MEM1[3]);
            word[ii-1] = (cM*MEM1[0])+(dM*MEM1[2]);
            word[ii] = (cM*MEM1[1])+(dM*MEM1[3]);

            ++ii;
        }
       
        if(counter < 3)
        {
            tempNUMS[counter] = encoded[ii];
        }

        ++counter;
        ++ii;
    }while(ii < word.size()); // word[i] != '\0'

    return word;
};


void DisplayCode(string word);


int main()
{
    string words;
    words = Gwin.getText(4);
    Criptic code;
    code.SetCodes();

    //----------------------------
    //encrypt tht mo fo'
    words = code.Encrypt(words);
    DisplayCode(words);
    //----------------------------


    //----------------------------
    //decrypt tht mo fo'
    words = code.Decrypt(words);
    DisplayCode(words);
    //----------------------------


    // Finally, wait for a key to be pressed
    Keyboard.getch();
   
    return 0;
}

void DisplayCode(string word)
{
    Gwin.writeString("   -   ");
    Gwin.writeString(word);
};

Name: OP 2010-10-04 14:44

that's some old code i wrote for it, i might sort it out later today as thats horrible to look at and read through, but it works (obviously on a closed system because MEM1 is a private key.

Name: Anonymous 2010-10-04 15:58

>>3,4
These two posts demonstrate the difference between the two types of /prog/ posters beautifully. Let's have more of >>3 and less of >>4.

Name: Anonymous 2010-10-04 16:50

>>4
Double?
What the fuck is wrong with you.

Name: Anonymous 2010-10-05 21:05

the best encryption would be to invent a new binary character, then noone would no about this character and u could use it and noone could decrypt it

Name: Anonymous 2010-12-17 1:39

This post brought to you by the Gay Nigger Association of America

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List