小编phi*_*888的帖子

使用 Rfc2898DeriveBytes 将 C# PBKDF2 转换为 PHP

长话短说,有一个内置于 .NET 的会员系统,我们正在将其移植到 WordPress,并且需要复制 PBKDF2 加密,这样用户就不需要重置他们的密码。

使用已知的散列密码,我可以使用以下代码轻松地在 .NET 中复制它:

static void Main(string[] args)
{
  var isValid = CheckPassword("#0zEZcD7uNmv", "5SyOX+Rbclzvvit3MEM2nBRaPVo2M7ZTs7n3znXTfyW4OhwTlJLvpcUlCryblgkQ");
}

public static int PBKDF2IterCount = 10000;
public static int PBKDF2SubkeyLength = 256 / 8; // 256 bits
public static int SaltSize = 128 / 8; // 128 bits

private static bool CheckPassword(string Password, string ExistingHashedPassword)
{
  byte[] saltAndPassword = Convert.FromBase64String(ExistingHashedPassword);
  byte[] salt = new byte[SaltSize];

  Array.Copy(saltAndPassword, 0, salt, 0, SaltSize);

  Console.WriteLine("--Salt--");
  Console.WriteLine(Convert.ToBase64String(salt));

  string hashedPassword = HashPassword(Password, salt);

  Console.WriteLine("--HashedPassword--");
  Console.WriteLine(hashedPassword);

  return …
Run Code Online (Sandbox Code Playgroud)

php c# wordpress pbkdf2

5
推荐指数
1
解决办法
3106
查看次数

使用ToList <T>转换Sitecore Item []的问题

使用Sitecore和Linq扩展.

我正在尝试使用以下代码将项目数组转换为列表:

Item variationsFolder = masterDB.SelectSingleItem(VariationsFolderID.ToString());
List<Item> variationList = variationsFolder.GetChildren().ToList<Item>();
Run Code Online (Sandbox Code Playgroud)

但是,每当我尝试构建时,我都会收到此错误:

'Sitecore.Collections.ChildList' does not contain a definition for 'ToList' and the best extension method overload 'System.Linq.Enumerable.ToList<TSource>(System.Collections.Generic.IEnumerable<TSource>)' has some invalid arguments
Run Code Online (Sandbox Code Playgroud)

我有以下用途:

using System.Linq;
using System.Xml.Linq;
Run Code Online (Sandbox Code Playgroud)

参考:

System.Core
Run Code Online (Sandbox Code Playgroud)

我刚刚从另一个位置复制了这个代码,所以它应该可以正常工作,只能认为有一些简单的东西(比如参考或我缺少的东西).

c# sitecore generic-list

1
推荐指数
1
解决办法
3401
查看次数

标签 统计

c# ×2

generic-list ×1

pbkdf2 ×1

php ×1

sitecore ×1

wordpress ×1