?
Solved

Ecrypt Password C#

Posted on 2010-08-15
4
Medium Priority
?
762 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
msimn earned 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

743 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