0% found this document useful (0 votes)
23 views

Demo On Encryption and Decryption

This document describes an application implemented in C# using Visual Studio .NET 3.5 that includes functions for encrypting and decrypting strings using DES encryption. It also mentions future enhancements like encrypting/decrypting files during transfer between a client and server.

Uploaded by

sivapandu
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Demo On Encryption and Decryption

This document describes an application implemented in C# using Visual Studio .NET 3.5 that includes functions for encrypting and decrypting strings using DES encryption. It also mentions future enhancements like encrypting/decrypting files during transfer between a client and server.

Uploaded by

sivapandu
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Sample Output Screen:

This application was implemented in c# and using an IDE Visual Studio .Net
3.5

Function for Encryption:

public static string Encrypt(string originalString)


{
if (String.IsNullOrEmpty(originalString))
{
throw new ArgumentNullException("The string which needs to
be encrypted can not be null.");
}

DESCryptoServiceProvider cryptoProvider = new


DESCryptoServiceProvider();
MemoryStream memoryStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(memoryStream,
cryptoProvider.CreateEncryptor(bytes, bytes), CryptoStreamMode.Write);

StreamWriter writer = new StreamWriter(cryptoStream);


writer.Write(originalString);
writer.Flush();
cryptoStream.FlushFinalBlock();
writer.Flush();
return Convert.ToBase64String(memoryStream.GetBuffer(), 0,
(int)memoryStream.Length);
}

Function for Decryption:


public static string Decrypt(string cryptedString)
{
if (String.IsNullOrEmpty(cryptedString))
{
throw new ArgumentNullException("The string which needs to
be decrypted can not be null.");
}

DESCryptoServiceProvider cryptoProvider = new


DESCryptoServiceProvider();
MemoryStream memoryStream = new
MemoryStream(Convert.FromBase64String(cryptedString));
CryptoStream cryptoStream = new CryptoStream(memoryStream,
cryptoProvider.CreateDecryptor(bytes, bytes), CryptoStreamMode.Read);
StreamReader reader = new StreamReader(cryptoStream);

return reader.ReadToEnd();
}

Future Enhancements:

Browse a file with private information which is shared between client and
server.

File type must be (.txt, .doc,.pdf,.rtf).

Above mentioned files can be uploaded to this application. Encrypted and


Decrypted during the file transferred from server to client and viceversa.

You might also like