Solved

Ecrypt Password C#

Posted on 2010-08-15
4
758 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 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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 …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

726 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