【问题标题】:What code it is and how to rewrite in php它是什么代码以及如何在php中重写
【发布时间】:2018-10-22 11:02:59
【问题描述】:

我从一个 api 提供者那里得到了这段代码

不确定它的 asp .net 还是什么

需要转成php

我尝试了一些在线工具,但没有运气。

有人帮助它是什么代码以及如何转换为 php。

            string CrypCode = (DateTime.Now.Year.ToString()+ (Seed + DateTime.Now.DayOfYear.ToString()));
            System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
            byte[] bs = System.Text.Encoding.UTF8.GetBytes(CrypCode);
            bs = x.ComputeHash(bs);
            System.Text.StringBuilder s = new System.Text.StringBuilder();
            foreach (byte b in bs)
            {
                s.Append(b.ToString("x2").ToLower());
            }
            string KEY = s.ToString();
            return KEY;

【问题讨论】:

  • 我们不是编码服务。向我们展示您迄今为止尝试过的代码。
  • 在我看来像 c#
  • @delboy1978uk 感谢您花时间尝试使用在线工具,您可以在我的问题中看到它
  • 我们需要看看你用的是什么PHP
  • @delboy1978uk 当我参考谷歌时,我什至不知道上面代码是用什么语言编写的写在

标签: php .net


【解决方案1】:

我记得我曾经使用 VB.NET。哈希是令人头疼的问题。我看到你正在尝试 md5 哈希密码。在 php 中它很简单。不知道为什么 Microsoft 语言会长期使用它。他们一定有他们的理由。信不信由你在 php 中只有一行。

$crypcode = date("Y") + ($seed + date("z"));
$key = md5($crypcode);
return $key;

http://php.net/manual/en/function.md5.php

http://php.net/manual/en/function.date.php

https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.md5cryptoserviceprovider

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-13
    相关资源
    最近更新 更多