Click here to Skip to main content
15,894,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am using this code to decrypt my password

C#
public class NetFourMembershipProvider : SqlMembershipProvider
{

public string GetClearTextPassword(string encryptedPwd)
{

    try
    {
        byte[] encodedPassword = Convert.FromBase64String(encryptedPwd);
        byte[] bytes = this.DecryptPassword(encodedPassword);
        if (bytes == null)
        {
            return null;
        }

        return Encoding.Unicode.GetString(bytes, 0x10, bytes.Length - 0x10);
    }
    catch (Exception)
    {

        throw;
    }

   }

}


This is my app.config file.



HTML
<configuration>
<system.web>
<machineKey validationKey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"        decryptionKey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" decryption="3DES"   validation="SHA1" />

<membership defaultProvider="AspNetSqlMembershipProvider" userIsOnlineTimeWindow="15">
  <providers>
    <clear />
    <add name="AspNetSqlMembershipProvider"
    type="System.Web.Security.SqlMembershipProvider"
    connectionStringName="SiteSqlServer" enablePasswordRetrieval="true"
    enablePasswordReset="true" requiresQuestionAndAnswer="false"
    minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="0"
    requiresUniqueEmail="false"
    passwordFormat="Encrypted"
    applicationName="DotNetNuke"
    description="Stores and retrieves ......." />
  </providers>
</membership>
<compilation debug="true" targetFramework="4.0" />
</system.web>





At this line
C#
byte[] bytes = this.DecryptPassword(encodedPassword);

I am getting the below error message.

"You must specify a non-autogenerated machine key to store passwords in the encrypted format. Either specify a different passwordFormat, or change the machineKey configuration to use a non-autogenerated decryption key."
How can I convert passwords.

Please help me.

Note:- The validationkey is 40 characters and decryptionKey is a 48 charectors long data.

Thanks in Advance
Posted

Don't bother to do it. Giving your code the ability to decrypt passwords is a HUGE security risk.
 
Share this answer
 
You could setup the encryption key. This post[^] describes a solution.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900