Hello,

I wanna call EncryptPassword/DecryptPassword methods of membershipProvider class,how can I call and use these methods,is there any one who can assist me,thanks a lot.

http://msdn2.microsoft.com/en-us/library/system.web.security.membershipprovider.aspx

thank you very much,solution code is end of the post.I want to ask another question,how can I get machineKey by giving password and encryped password??

/// <summary>
/// Sample code that exposes the protected DecryptPassword and EncryptPassword as public
/// </summary>
public class MyMembershipProvider extends System.Web.Security.MembershipProvider
{
     /// <summary>
     /// Allows public access to protected member 
     /// </summary>
     /// <param name="encodedPassword"></param>
     /// <returns></returns>
     public new byte[] DecryptPassword(byte[] encodedPassword)
     {
         return base.DecryptPassword(encodedPassword);
     }

     /// <summary>
     /// Allows public access to protected member
     /// </summary>
     /// <param name="password"></param>
     /// <returns></returns>
     public new byte[] EncryptPassword(byte[] password)
     {
          return base.EncryptPassword(password);
     }
}

// Sample code to encrypt/decrypt data
MyMembershipProvider myMembershipProvider = new MyMembershipProvider();
// Use base64 string when storing data in a varchar instead of a blob.
string encryptedData = Convert.ToBase64String(myMembershipProvider.EncryptPassword(ASCIIEncoding.ASCII.GetBytes("text to ecrypt")));
string decryptedValue = ASCIIEncoding.ASCII.GetString(myMembershipProvider.DecryptPassword(Convert.FromBase64String(encryptedData));

Im not quite sure I understand the question to be honest

Im not quite sure I understand the question to be honest

ok,I have a database and there are encoded passwords and I know the decoded password;for example pass="test" encodedpassword="574a11a6-ac16-4431-9559-90c959944414 " ,hence I want to find out which validationKey produce this encoded password...I wanna figure out validationKey or machineKey.

hmm ok ill get bak to you on that

are you trying to crack the microsoft decryption keys? lol

I write my own encryption and decryption methods. The problem with microsoft's version is that the encryption method is the same all around. So if you have two passwords that let's say equal "googlybear", they will look the same and be the same encryption. (Both will look exactly the same). I wrote a simple encryption and decryption method that will guarantee each password encryption to be completely different. I suggest you do the same :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.