tags:

views:

136

answers:

6

I want to encrypt the serail numbers of hard disk,mother board etc.can u please suggest some good mathematical equations for encryption?

A: 

http://code.google.com/p/zscreen/source/browse/trunk/ZScreenLib/Helpers/PasswordManager.cs has methods to encrypt and decrypt a string. That's a start. :)

McoreD
+3  A: 

System.Security.Cryptography Namespace
http://msdn.microsoft.com/en-us/library/system.security.cryptography.aspx

XXXXX
A: 

As you mention C# I'd advise looking at the .NET framework Cryptography namespace.

You should use one of the algorithms provided for you here rather then looking to implement your own.

Also see this previous question Best way to encrypt short strings in .NET

Ash
+8  A: 

A general rule of thumb involving encryption is, if you haven't done it before, you're going to do it wrong. If the encryption is important, then use someone else's package (that you have source to, preferably, so that they don't introduce backdoors), because they will have ironed out the bugs. Check out Schneier's book on Crypto for some general equations and implementations.

But, if you just want to use encryption and not really mess with implementing it (even if that's just copying over code from the book), then check out the encryption namespace that others have mentioned.

mmr
This is sound advice.
Robert Venables
Ditto! Great answer!
TrueWill
A: 

Depends on what do you want to use them for. There's plenty of algorithms implemented in System.Security.Cryptography namespace.

If you want to encrypt the data and send them to other machine and decrypt them there your best bet is asymmetric encryption, eg. RSA.

If you are fine with only encoding the data and then comparing them, but never decoding them your best bet is to use a hash, like SHA-1.

If you just want to mask the string, you can plainly XOR each character with some predefined constant and then decode by doing the very same process:

private static string key = "MySecretKey";
private static byte[] keyData = Encoding.ASCII.GetBytes(key);

public static byte[] Encrypt(byte[] source)
{
 byte[] target = new byte[source.Length];

 for (int i = 0; i < target.Length; i++)
  target[i] = (byte)(source[i] ^ keyData[i % keyData.Length]);

 return target;
}
Filip Navara
A: 

The BouncyCastle C# edition might also offer you some interesting features beyond the .NET Cryptography.

typeseven