Re: [Vala] encrypt decrypt



El 22/10/11 12:40, "Luis L. Rodríguez Oro" escribió:
El 22/10/11 11:05, pancake escribió:
What do you want from us? Implement a criptografic algorithm for you?

There are several criptographic algorithms to do that. Check wikipedia.

If you do not specify the algo we cant help, as long as its your own choice and your choice to implement it from scratch or use any of the available opensource libraries out there.

On 22/10/2011, at 16:52, "Luis L. Rodríguez Oro"<luisr uci cu>  wrote:

I need encrypt and decrypt come text:

string decrypt(string text, string password){
// code

return decrypted;
}


string encrypt(string text, string password){
// code

return encrypted;
}

void main(){
    string text = "hello word";
    string pass = "p4ssw0rd";

    string enc = encrypt(text, pass);
    print("%s\", enc);

    string orig = decrypt(enc, pass);
    print("%s\",orig);
}

I appreciate any help.
Thanks for every body.
Luis



I only need encrypt some password to save to configuration.conf, I need decrypt the password to used, MD5 don't work to me. I prefer use some library.
I've only used vala for 3 days, before that PHP.

Where is the encripted password and how decript it?

http://en.wikipedia.org/wiki/RC4
http://es.wikipedia.org/wiki/RC4

int S[255];
int i;
int j;

void swap(int i, int j) {
    int temp = S[i];
    S[i] = S[j];
    S[j] = temp;
}

/* KSA */
void rc4_init(string key) {
    int key_length = key.length;
    for (i = 0; i < 256; i++)
        S[i] = i;

    for (i = j =0; i < 256; i++) {
        j = (j + key[i % key_length] + S[i]) & 255;
        swap(i, j);
    }

    i = j =0;
}

/* PRGA */
int rc4_output() {
    i = (i + 1) & 255;
    j = (j + S[i]) & 255;

    swap(i, j);

    return S[(S[i] + S[j]) & 255];
}

void main() {
    string pass ="Key";
    string text = "Plaintext";
    rc4_init(pass);

    unichar c;
    //var p;
    for (int i = 0; text.get_next_char (ref i, out c);) {
        int data = int.parse("%d".printf((char) c));
        var keystream = rc4_output();

        var p = data ^ keystream;
        print("%d ",p);
    }

    print("\n");


}


Fin a la injusticia, LIBERTAD AHORA A NUESTROS CINCO COMPATRIOTAS QUE SE ENCUENTRAN INJUSTAMENTE EN PRISIONES 
DE LOS EEUU!
http://www.antiterroristas.cu
http://justiciaparaloscinco.wordpress.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]