Solved

Ecrypt Password C#

Posted on 2010-08-15
4
754 Views
Last Modified: 2012-05-10
Hi Experts, i need a simple solution .
i have a program i wrote in C# the requiers gmail user name and password inorder to send email notification to the user.
i currntly store these details is the registry , i would like to encrypt the password.
so if someone explores the registry using regedit he won't be able to extract the password.

this is in C# (Visual Studio 2010)
Thanks
0
Comment
Question by:logicthought
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
msimn earned 500 total points
ID: 33439722
Try visiting this website:
http://www.dijksterhuis.org/encrypting-decrypting-string/

You will still need to create a passphrase which you might hardcode it in your program.
0
 
LVL 3

Expert Comment

by:msimn
ID: 33439732
Or, you might try a salted base-64 encode as the following example.

Note that you might want to change the string manipulation part to anything you could think of.
public static string EncodeTo64(string toEncode)
    {
      byte[] toEncodeAsBytes
            = System.Text.ASCIIEncoding.ASCII.GetBytes(toEncode);
      string returnValue
            = System.Convert.ToBase64String(toEncodeAsBytes);
      return (new Random()).Next(0, 9) + returnValue + (new Random()).Next(0, 9);
    }

public static string DecodeFrom64(string encodedData)
    {
      encodedData = encodedData.substring(1, encodedData.Length - 2);
      byte[] encodedDataAsBytes
          = System.Convert.FromBase64String(encodedData);
      string returnValue =
         System.Text.ASCIIEncoding.ASCII.GetString(encodedDataAsBytes);
      return returnValue;
    }

public static void main(String[] args)
    {
      string encodedPassword = EncodeTo64("MyPassword");
      Console.WriteLine("Encoded password = " + encodedPassword);

      string decodedPassword = DecodeFrom64(encodedPassword);
      Console.WriteLine("Decoded password = " + decodedPassword);
    }

Open in new window

0
 
LVL 12

Expert Comment

by:starlite551
ID: 33444157
I hope this works for u.. I am attaching a .cs file with my comment plz do check it..
EncryptDecrypt.cs
0
 
LVL 12

Expert Comment

by:starlite551
ID: 33444159
Compile this above file using the command line compiler which comes with visual studio.. as follows :
csc /t:winexe EncryptDecrypt.cs  
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to get the web content with different encodings 2 46
SqlDataBase 7 48
Problem!!! 8 33
HTML - Color not displaying correctly in EMAIL. 6 39
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question