关于using System.Web.Configuration怎么也想不通的问题?【100分】求解

敦厚的曹操 2013-06-11 12:12:34



using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Web.Configuration;
using System.Web.Security;


/// <summary>
/// HanShu 的摘要说明
/// </summary>
public class jami
{
public jami() { }


public static string DecryptDBStr(string Text, string sKey) // 【验证=8】
{

return MachineKeySection.ByteArrayToHexString(algorithm.ComputeHash(Encoding.UTF8.GetBytes(password)), 0);

}


}



=============================================================
郁闷死了,哪位高手能给点拨一下!
using System.Web.Configuration;已经有了,怎么就没有ByteArrayToHexString





...全文
330 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
moonwrite 2013-06-11
  • 打赏
  • 举报
回复
http://msdn.microsoft.com/en-us/library/microsoft.biztalk.snapin.framework.querybuilder.streamparser.bytearraytohexstring(v=bts.20).aspx Namespace: Microsoft.BizTalk.SnapIn.Framework.QueryBuilder Assembly: Microsoft.BizTalk.SnapIn.Framework (in microsoft.biztalk.snapin.framework.dll)
敦厚的曹操 2013-06-11
  • 打赏
  • 举报
回复
就是不行呀,谁有心可以在自己的环境试试这段代码或查一下自己的using System.Web.Configuration;是否有ByteArrayToHexString 解决不了,如果真正解决了,不行再送100分。
Justin-Liu 2013-06-11
  • 打赏
  • 举报
回复
要么是程序集版本不对应 要么是此方法没有public
superliu1122 2013-06-11
  • 打赏
  • 举报
回复
internal static unsafe string ByteArrayToHexString(byte[] buf, int iLen) internal的,你在外面当然看不到了
饕餮123 2013-06-11
  • 打赏
  • 举报
回复
引用 6 楼 Return_false 的回复:
System.Web.Configuration.MachineKeySection 中已经提供了一个名为 ByteArrayToHexString 方法,但是该方法是NonPublic 的,我们不能直接调用。这里我们通过反射来调用 MachineKeySection 中的 ByteArrayToHexString 方法。
 /// <summary>
        /// 字节数组转换为16进制表示的字符串
        /// </summary>
        public static string ByteArrayToHexString(byte[] buf)
        {
            int iLen = 0;

            // 通过反射获取 MachineKeySection 中的 ByteArrayToHexString 方法,该方法用于将字节数组转换为16进制表示的字符串。
            Type type = typeof(System.Web.Configuration.MachineKeySection);
            MethodInfo byteArrayToHexString = type.GetMethod("ByteArrayToHexString", BindingFlags.Static | BindingFlags.NonPublic);

            // 字节数组转换为16进制表示的字符串
            return (string)byteArrayToHexString.Invoke(null, new object[] { buf, iLen });
        }
+1
  • 打赏
  • 举报
回复
System.Web.Configuration.MachineKeySection 中已经提供了一个名为 ByteArrayToHexString 方法,但是该方法是NonPublic 的,我们不能直接调用。这里我们通过反射来调用 MachineKeySection 中的 ByteArrayToHexString 方法。
 /// <summary>
        /// 字节数组转换为16进制表示的字符串
        /// </summary>
        public static string ByteArrayToHexString(byte[] buf)
        {
            int iLen = 0;

            // 通过反射获取 MachineKeySection 中的 ByteArrayToHexString 方法,该方法用于将字节数组转换为16进制表示的字符串。
            Type type = typeof(System.Web.Configuration.MachineKeySection);
            MethodInfo byteArrayToHexString = type.GetMethod("ByteArrayToHexString", BindingFlags.Static | BindingFlags.NonPublic);

            // 字节数组转换为16进制表示的字符串
            return (string)byteArrayToHexString.Invoke(null, new object[] { buf, iLen });
        }
  • 打赏
  • 举报
回复
程序集版本? net 4.0 ?

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧