PasswordRecoveryProvider Sınıfı
using System;
using System.Configuration.Provider;
using System.Text;
using System.Web.Security;
public class PasswordRecoveryProvider : MembershipProvider
{
private static readonly PasswordRecoveryProvider _instance = new PasswordRecoveryProvider();
public override MembershipPasswordFormat PasswordFormat
{
get { return MembershipPasswordFormat.Encrypted; }
}
public static string RecoverMembershipEncryptedString(string target)
{
try
{
// Decode the password in Base64
byte[] data = Convert.FromBase64String(target);
// Use internal method to decrypt by machine key
byte[] decrypted = _instance.DecryptPassword(data);
// Encode the decrypted data to readable format
string encoded = Encoding.Unicode.GetString(decrypted);
// Remove the salt value prepended to the value
string clean = encoded.Substring(8);
// Return the password
return clean;
}
catch (ProviderException)
{
// No machine key?
return target;
}
}
#region Not Implemented
public override bool EnablePasswordRetrieval
{
get { throw new NotImplementedException(); }
}
public override bool EnablePasswordReset
{
get { throw new NotImplementedException(); }
}
public override bool RequiresQuestionAndAnswer
{
get { throw new NotImplementedException(); }
}
public override string ApplicationName
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
public override int MaxInvalidPasswordAttempts
{
get { throw new NotImplementedException(); }
}
public override int PasswordAttemptWindow
{
get { throw new NotImplementedException(); }
}
public override bool RequiresUniqueEmail
{
get { throw new NotImplementedException(); }
}
public override int MinRequiredPasswordLength
{
get { throw new NotImplementedException(); }
}
public override int MinRequiredNonAlphanumericCharacters
{
get { throw new NotImplementedException(); }
}
public override string PasswordStrengthRegularExpression
{
get { throw new NotImplementedException(); }
}
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion,
string passwordAnswer, bool isApproved, object providerUserKey,
out MembershipCreateStatus status)
{
throw new NotImplementedException();
}
public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion,
string newPasswordAnswer)
{
throw new NotImplementedException();
}
public override string GetPassword(string username, string answer)
{
throw new NotImplementedException();
}
public override bool ChangePassword(string username, string oldPassword, string newPassword)
{
throw new NotImplementedException();
}
public override string ResetPassword(string username, string answer)
{
throw new NotImplementedException();
}
public override void UpdateUser(MembershipUser user)
{
throw new NotImplementedException();
}
public override bool ValidateUser(string username, string password)
{
throw new NotImplementedException();
}
public override bool UnlockUser(string userName)
{
throw new NotImplementedException();
}
public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
{
throw new NotImplementedException();
}
public override MembershipUser GetUser(string username, bool userIsOnline)
{
throw new NotImplementedException();
}
public override string GetUserNameByEmail(string email)
{
throw new NotImplementedException();
}
public override bool DeleteUser(string username, bool deleteAllRelatedData)
{
throw new NotImplementedException();
}
public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
{
throw new NotImplementedException();
}
public override int GetNumberOfUsersOnline()
{
throw new NotImplementedException();
}
public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize,
out int totalRecords)
{
throw new NotImplementedException();
}
public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize,
out int totalRecords)
{
throw new NotImplementedException();
}
#endregion
}Revovery uygulama sınıfı :
string password = "hbJtIKn8CDMTyFBZS/nleu4kZf5Q2UNWVWGHWlcal2NYQ3t2scYL+DhcpBGlolDE";
string answer = "hbJtIKn8CDMTyFBZS/nleniH1bSX6JH17lxq0zW+tqc=";
// admin parolası bulma için uygulama
string recoveredPassword = PasswordRecoveryProvider.RecoverMembershipEncryptedString(password);
string recoveredAnswer = PasswordRecoveryProvider.RecoverMembershipEncryptedString(answer);Web.Config Dosyası
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<machineKey validationKey='365B53DCCF1212FBD0AD48147CF0D56E2B68CC29282329B48431DF2AC97E6E6857A312D4D5C3E7A0A302FE30AAA9AF7C6BC106A05F0F19C3639766D02E5880A8'
decryptionKey='814385B5A3B3B89F1EDD5ED419DA54764AA7BE94ECA2E6B9'
validation='SHA1'
decryption='Auto'/>
<membership defaultProvider="SqlMembershipProvider"
userIsOnlineTimeWindow="15"
hashAlgorithmType="">
<providers>
<clear />
<add name="SqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="LocalSqlServer"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresUniqueEmail="true"
passwordFormat="Encrypted"/>
</providers>
</membership>
<compilation debug="true"/>
<authentication mode="Forms" />
</system.web>
</configuration>