[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Ecrypt Password C#

Posted on 2010-08-15
4
Medium Priority
?
763 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

650 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