I created a page called "RunCode.aspx".
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MonoSoftware.MonoX.Extensions;
using System.Security.Cryptography;
using SD.LLBLGen.Pro.ORMSupportClasses;
using MonoSoftware.MonoX.DAL.HelperClasses;
using MonoSoftware.MonoX.DAL.EntityClasses;
using MonoSoftware.MonoX.DAL;
namespace MonoSoftware.MonoX.Pages
{
public partial class RunCode : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
}
internal void SwitchAllUserPasswordsToHashFormat()
{
UnitOfWork2 uow = new UnitOfWork2();
EntityCollection<
AspnetMembershipEntity
> usersPass = new EntityCollection<
AspnetMembershipEntity
>();
RelationPredicateBucket bucketPass = new RelationPredicateBucket();
bucketPass.PredicateExpression.Add(AspnetMembershipFields.PasswordFormat == 0);
PrefetchPath2 pp = new PrefetchPath2(EntityType.AspnetMembershipEntity);
pp.Add(AspnetMembershipEntity.PrefetchPathAspnetUsers);
FetchEntityCollection(usersPass, bucketPass, 0, null, pp);
foreach (AspnetMembershipEntity user in usersPass)
{
if (string.IsNullOrEmpty(user.PasswordSalt))
user.PasswordSalt = CreateSalt();
user.Password = EncodePassword(user.Password, user.PasswordSalt);
user.PasswordFormat = 1;
uow.AddForSave(user, true);
}
CommitUnitOfWork(uow, true);
}
internal string CreateSalt()
{
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
byte[] buff = new byte[32];
rng.GetBytes(buff);
return Convert.ToBase64String(buff);
}
internal string EncodePassword(string pass, string saltBase64)
{
byte[] bytes = Encoding.Unicode.GetBytes(pass);
byte[] src = Convert.FromBase64String(saltBase64);
byte[] dst = new byte[src.Length + bytes.Length];
Buffer.BlockCopy(src, 0, dst, 0, src.Length);
Buffer.BlockCopy(bytes, 0, dst, src.Length, bytes.Length);
HashAlgorithm algorithm = HashAlgorithm.Create("SHA1");
byte[] inArray = algorithm.ComputeHash(dst);
return Convert.ToBase64String(inArray);
}
}
}
Error 104 The name 'FetchEntityCollection' does not exist in the current context C:\Users\Downloads\Projects\MonoX\RunCode.aspx.cs 32 13 C:\...\MonoX\
Error 105 The name 'CommitUnitOfWork' does not exist in the current context C:\Users\Downloads\Projects\MonoX\RunCode.aspx.cs 42 13 C:\...\MonoX\
Error 106 The name 'Encoding' does not exist in the current context C:\Users\Downloads\Projects\MonoX\RunCode.aspx.cs 55 28 C:\...\MonoX\
Error 107 'bool' does not contain a definition for 'BlockCopy' and no extension method 'BlockCopy' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?) C:\Users\Downloads\Projects\MonoX\RunCode.aspx.cs 58 20 C:\...\MonoX\
Error 108 'bool' does not contain a definition for 'BlockCopy' and no extension method 'BlockCopy' accepting a first argument of type 'bool' could be found (are you missing a using directive or an assembly reference?) C:\Users\Downloads\Projects\MonoX\RunCode.aspx.cs 59 20 C:\...\MonoX\