M
msnews.microsoft.com
How can I encrypt and decrypt string?
msnews.microsoft.com said:How can I encrypt
if you do not publish the protection string, your encrypted string in
unbreakable!
Sherif ElMetainy said:Hello
The XOR method is breakable is someone has an encrypted string and a clear
text string.
If you XOR the clear text string and the encrypted string you get the
protection string
if you do not publish the protection string, your encrypted string in
unbreakable!
unbreakable!
Ron McNulty said:No, not quite!
If you have the facility to run your own code against the algorithm, it can
be easily broken. An example would be where you can read a password field in
a database, and see what your own (known) password "encrypts" to. Anyone
with basic cryptography knowledge should be able to glean the encryption key
within an hour. And being a symmetrical algorithm, you can run it against
all other passwords and get the plaintext.
Then you can try those passwords against other machines that the users may
have access to.... Your hacking career has begun!
Operating systems based on UNIX have been using salted encryption algorithms
for years. These are reasonably safe, although not unbreakable.
The "unbreakable" that you refer to is for one-time pads, and these are not
the norm in computer systems.
Sherif ElMetainy said:Hello
Give me a clear text string, a string encrypted with your hidden key using
the XOR method.
Then give me another string encrypted with the same key, it will take me
less than one minute to decrypt it, because I will know the key.
Consider the following scenario.
Suppose I have a web site, where the member's passwords are stored encrypted
using XOR in a database.
Some how a hacker was able to gain access to the database (due to a security
hole, new vulnerability, unpatched server, bad administrator, etc), but he
doesn't have access to the key to decrypt the passwords.
So he registers a new account for himself in my web site (he knows the
password for this account because he created it), then he looks at his own
ecrypted password.
Now he can easily know the encryption key, and can decrypt all other
passwords.
Sherif ElMetainy said:XOR is breakable
and below is a code to demonstrate, i am using ints, but
the same applies to strings
Random r = new Random();
int secret = r.Next(); // this is hidden
int clear = r.Next(); // i know this one
int encrypted = secret ^ clear; // i know this one too
int hacked = encrypted ^ clear; // now i know the secret
Console.WriteLine(hacked == secret);
Sherif ElMetainy said:I was talking about reusing the key, which is the case in most scenarios In
this case it is breakable.