简体   繁体   English

它是什么代码以及如何在 php 中重写

[英]What code it is and how to rewrite in php

i have got this code from one of api provider我从一个 api 提供者那里得到了这个代码

Not sure its asp .net or something不确定它的 asp .net 或其他东西

Need to convert to php需要转换成php

i tried with some online tools, no luck.我尝试了一些在线工具,但没有运气。

Some One help what code it is and how i can convert to php. Some One 帮助它是什么代码以及我如何转换为 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;

I remember when i used to work with VB.NET.我记得当我曾经使用 VB.NET 时。 Hashing is headache.哈希很头疼。 I see you are trying to md5 hash crypcode.我看到你正在尝试 md5 哈希密码。 In php its simple.在 php 中它很简单。 Dont know why Microsoft languages long it out.不知道为什么微软的语言很长。 They must have their reasons.他们一定有他们的理由。 Believe it or not in php its one line.信不信由你在 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.md5.php

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM