I want to encrypt the serail numbers of hard disk,mother board etc.can u please suggest some good mathematical equations for encryption?
-
4Encryption is a security tool designed to mitigate specific vulnerabilities to specific threats. Encryption is not magic dust you sprinkle on a thing to make it "more secure". Before you even consider using encryption to solve a security problem, first do a detailed threat model that describes precisely what resource you are protecting, how it is vulnerable, what threats you consider dangerous, who the attackers are, and so on. Only once you have a detailed threat model should you try to figure out whether encryption is a useful tool, and if so, what kind of encryption to use. – Eric Lippert Aug 31 '09 at 15:47
6 Answers
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.

- 14,781
- 29
- 95
- 145
System.Security.Cryptography Namespace
http://msdn.microsoft.com/en-us/library/system.security.cryptography.aspx

- 1,076
- 1
- 8
- 13
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. :)

- 313
- 2
- 12
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
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;
}

- 4,818
- 1
- 26
- 37
The BouncyCastle C# edition might also offer you some interesting features beyond the .NET Cryptography.

- 810
- 6
- 8