通过PHP

时间:2018-08-28 09:45:49

标签: php asp.net-mvc cryptography aes

我花了半天的时间来弄清楚我遇到的问题,而且看来我已经走到了尽头。

我有一个ASP应用程序(无法访问实际代码,仅能访问数据库),其中用户密码存储在aspnet_membership>“密码”列中,它也有一个标志。

我还获得了机器密钥文件的副本,据我了解,该副本包含需要解密密码的密钥?

 <machineKey validationKey="**validation key**" decryptionKey="**decryption key**" validation="SHA1" decryption="AES"/>

我已经尝试了很多不同的方法,例如使用开放的ssl,使用不同的库等。但是,我似乎对此缺乏知识。我目前正在尝试使用https://github.com/phpseclib/phpseclib库来解密密码:

$cipher = new AES(); // could use AES::MODE_CBC
        // keys are null-padded to the closest valid size
        // longer than the longest key and it's truncated
        //$cipher->setKeyLength(128);
        $cipher->setKey(**decrypt key**);
        // the IV defaults to all-NULLs if not explicitly defined
        $cipher->setIV($salt);

        echo $cipher->decrypt($password);

无论我以何种方式尝试执行此操作,都会得到随机返回或错误。我在ASP应用程序上运行的AES版本或其他任何加密信息的信息非常有限。任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:-1)

您好,此MachineKey与Salt无关,salt是在运行时使用提供的密码由代码生成的。

.NET框架使用Rfc2898DeriveBytes进行加密 像这样

using (Rfc2898DeriveBytes rfc2898DeriveByte = new Rfc2898DeriveBytes(password, 16, 1000))
        {
            salt = rfc2898DeriveByte.Salt;
            bytes = rfc2898DeriveByte.GetBytes(32);
        }
相关问题