PDA

View Full Version : encrypt function


Chompy
05-02-2008, 08:50 AM
This is a little encrypt function I made, attached below

44536

Now, there are 3 arguments, encrypt(string, key, buffer);

String can be anything from "foo" to "Hi there, I'm Chompy and this text is going to be encrypted".

Key is just an extra factor to the encryption, it can be whatever you want it to be

Buffer, this is the length of the string that you will get in return, can be any length, from 1 to 100 or more

Remember, the longer the arguments are, the longer it takes to encrypt, logical :p


anyways, some examples:


function onCreated() {
echo(encrypt("foo", "bar", 8)); // FrvUqQuU
echo(encrypt("Hi there, I'm Chompy", "key", 8)); // lCAP4FFy
echo(encrypt("Hi there, I'm Chompy", "key", 6)); // YkI6IL
echo(encrypt("wee, I'm being encrypted!", "yep", 16)); // b845MaTRcmOG4EjC
echo(encrypt("baz", "bar", 24)); // 3hBPVspQmuKQ1PrAvuG4FmdL
echo(encrypt("foo", "foo", 10)); // 4KjCpuokgC
}


:) How effective it is,.. I don't know how to measure that, but it does the job.

If you find any bugs and such, feel free to post them :o

Tigairius
05-02-2008, 09:55 AM
Oooh nice, looks like it was fun to make :p

05-02-2008, 08:39 PM
how to decode?

Crow
05-02-2008, 08:42 PM
how to decode?

Doesn't look like you can, but I don't think you need to decode encrypted things all the time.

05-02-2008, 08:48 PM
he didn't post one, i don't see a point in encoding things anyway, most people wouldn't even know how to decode an md5 hash tbh, well in Graal anyway

Programmer
05-02-2008, 08:58 PM
he didn't post one, i don't see a point in encoding things anyway, most people wouldn't even know how to decode an md5 hash tbh, well in Graal anyway

MD5 is a one-way hash. It can't be decoded.

05-02-2008, 08:59 PM
http://www.md5decrypter.com/

Programmer
05-02-2008, 09:04 PM
http://www.md5decrypter.com/

They store a database of all words and phrases encrypted through the website. For example, try to decrypt this:

d38cbe1816dd0c9919ebfba20f654fca

Literal text:
"This is a test to see if MD5 decrypter can actually decrypt MD5..."

You'll see that it won't work.

05-02-2008, 09:08 PM
who would use that as a password?

i see your point though

Skyld
05-02-2008, 09:11 PM
who would use that as a password?

i see your point though
Dude, the string he posted is an MD5 hash of some text, not actual text.

What his point is that the only way that website works is by trying things they've already stored in their database. No "decryption" (even though encryption/decryption is the wrong word for MD5 hashing) is taking place.

Tolnaftate2004
05-02-2008, 10:05 PM
You measure encryption effectiveness in (at least) two ways:
1. Is it feasible to easily determine two (or more) strings producing the same encrypted string?
2. Is it likely that two similar strings produce similar encrypted strings?

Yours passes both. Well done.

DustyPorViva
05-02-2008, 10:16 PM
Is there ever a need to decode? When I was learning PHP I remember reading about encrypting and such and you never need to decode an encryption, simply taking inputted text and encrypting it and comparing it to the already encrypted text.

Tolnaftate2004
05-02-2008, 10:19 PM
Is there ever a need to decode?

Yes, sometimes it is useful for securely transferring data, e.g., SSH.

05-02-2008, 11:06 PM
Oh, I get it coool he he