public bool SetPassword(string userName, string currentPassword, string newPassword) { string currentPasswordHash = BitConverter.ToString(HashAlgorithm.Create("SHA256").ComputeHash(Encoding.ASCII.GetBytes(currentPassword))).ToLower().Replace("-", ""); string newPasswordHash = BitConverter.ToString(HashAlgorithm.Create("SHA256").ComputeHash(Encoding.ASCII.GetBytes(newPassword))).ToLower().Replace("-", ""); CriticalResultsEntityManager manager = new CriticalResultsEntityManager(); UserEntity ue = manager.GetUser(userName); UserEntryEntity passwordEntity = null; foreach (UserEntryEntity uee in ue.UserEntries) { if (uee.Type == "AuthExt" && uee.Key == "ANCR") { passwordEntity = uee; } } if (passwordEntity == null) return false; else { if (passwordEntity.Value == currentPasswordHash) { return manager.UpdateUserEntryEntity(userName, "AuthExt", "ANCR", newPasswordHash, true); } return false; } }