java 写的 desc 解密方法怎么用 PHP 还原

/// 解密数据
///
///
///
///
public static string Decrypt(string Text, string sKey)
{
DESCryptoServiceProvider des = new DESCryptoServiceProvider();//调一个desc的类
int len;//声明整数len的变量
len = Text.Length / 2;//把需要解密的字符长度除以2复制给len
byte[] inputByteArray = new byte[len];//声明数组长度为len 赋值给inputByteArray
int x, i;//声明整数x,i
for (x = 0; x < len; x++)
{
i = Convert.ToInt32(Text.Substring(x * 2, 2), 16);//将密码字符串每次取两位在转化成32位的符号整数 再取其16 位有符号整数的值转换为等效的 32 位有符号整数。
inputByteArray[x] = (byte)i;//把得到的符号整数 赋给数组inputByteArray
}
des.Key = ASCIIEncoding.ASCII.GetBytes
(System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile
(sKey, "md5").Substring(0, 8)); //把密钥进行MD5后,取字符串0到8位

        des.IV = ASCIIEncoding.ASCII.GetBytes
    (System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile
    (sKey, "md5").Substring(0, 8));//把密钥进行MD5后,取字符串0到8位

        System.IO.MemoryStream ms = new System.IO.MemoryStream();//应该也是调一个MemoryStream的类吧

        CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write);
    //调CryptoStream类  并且传入参数 ms应该是执行的方式   des.CreateDecryptor() 用8位字符串
    创建对称解密器对象  CryptoStreamMode.Write  加密

        cs.Write(inputByteArray, 0, inputByteArray.Length);//上一步的结果解密后的数据放入内存流

        cs.FlushFinalBlock();//用缓冲区的当前状态更新基础数据源或储存库,随后清除缓冲区。

        return Encoding.UTF8.GetString(ms.ToArray());//按照UTF8的编码方式得到字符串
    }

我写的解释不晓得对不对 我想问下laravel里怎么代替里面的DESCryptoServiceProvider()方法 MemoryStream()方法 CryptoStream()方法

《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 1

@Summer 不好意思老大 第一次发 以为没发出去就多点了一下 后面找到其他方法了

6年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!