Encrypting and Decrypting Numbers with .NET?

Encryption (which is provided by the . NET framework / BCL, not C# the language) typically works on bytes. But that is fine; numbers are easy to represent as bytes, and the output bytes can be written as a string via Convert.

ToBase64String.

Encryption (which is provided by the . NET framework / BCL, not C# the language) typically works on bytes. But that is fine; numbers are easy to represent as bytes, and the output bytes can be written as a string via Convert.

ToBase64String. So "all of them, indirectly"... See System.Security. Cryptography on MSDN (re decrypting: an encryption can be decrypted; a hash cannot (hopefully); so as long as you don't look at hashing functions, you should be fine).

Thanks, Marc, I was just going to mention that C# doesn't do encryption. – John Saunders Jul 29 '09 at 13:53 Agreed that the . NET is semantically correct.

However, I think you may want to leave a reference to C# in the original question. People coding in C# will be looking for a solution written out in that language, regardless of the location of the libraries. Since "Google is the homepage" there is value in allowing questions to be worded in what may be a popular phrasing, even if not semantically perfect.

– Traples Jul 29 '09 at 14:04 Does that keep everyone happy? – Marc Gravell? Jul 29 '09 at 14:20 1 Yes, my happiness is directly tied to the inclusion of two words in a obscure post on SO :) Achieving this level of satiation, I'm off to the lecture circuit to capitalize on it.

– Traples Jul 29 '09 at 15:48.

System.Security. Cryptography - The System.Security. Cryptography namespace provides cryptographic services, including secure encoding and decoding of data, as well as many other operations, such as hashing, random number generation, and message authentication.

Example Walkthrough demonstrates how to encrypt and decrypt content.

Whatever you do, don't roll your own encryption algorithm. The System.Security. Cryptography namespace will contain everything you need: using System; using System.Collections.

Generic; using System. Text; using System.Security. Cryptography; namespace ConsoleApplication1 { class Program { static void Main(string args) { String secret = "Zomg!"; byte secretBytes = ASCIIEncoding.ASCII.

GetBytes(secret); // One-way hashing String hashedSecret = BitConverter. ToString( SHA512Managed.Create(). ComputeHash(secretBytes) ); // Encryption using symmetric key Rijndael rijndael = RijndaelManaged.Create(); ICryptoTransform rijEncryptor = rijndael.CreateEncryptor(); ICryptoTransform rijDecryptor = rijndael.CreateDecryptor(); byte rijndaelEncrypted = rijEncryptor.

TransformFinalBlock(secretBytes, 0, secretBytes. Length); String rijndaelDecrypted = ASCIIEncoding.ASCII. GetString( rijDecryptor.

TransformFinalBlock(rijndaelEncrypted, 0, rijndaelEncrypted. Length) ); // Encryption using asymmetric key RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); string rsaParams = rsa. ToXmlString(true); // you can store the public key in a config file // which allows you to recreate the file later byte rsaEncrypted = rsa.

Encrypt(secretBytes, false); String decrypted = ASCIIEncoding.ASCII. GetString( rsa. Decrypt(rsaEncrypted, false) ); // Signing data using the rsaEncryptor we just created byte signedData = rsa.

SignData(secretBytes, new SHA1CryptoServiceProvider()); bool verifiedData = rsa. VerifyData(secretBytes, new SHA1CryptoServiceProvider(), signedData); } } }.

I would start by looking at the Cryptography namespace. You can implement your own decrypt/encrypt string functions. Here is a good example.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions