为什么的我引用不了MD5的命名空间

qq_30440553 2017-03-10 02:36:26
Md5Helper.EncryptString(),我想要引用来加密 发现引用不了 。 是我VS的问题吗? VS2013
...全文
292 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_30440553 2017-03-10
  • 打赏
  • 举报
回复
引用 8 楼 starfd 的回复:
Md5Helper是别人封装的代码,给你一个差不多的封装代码
    public class Digest
    {
        public static string MD5Of(string text)
        {
            return MD5Of(text, Encoding.Default);
        }
        public static string MD5Of(string text, Encoding enc)
        {
            return HashOf<MD5CryptoServiceProvider>(text, enc);
        }
        public static string SHA1Of(string text)
        {
            return SHA1Of(text, Encoding.Default);
        }
        public static string SHA1Of(string text, Encoding enc)
        {
            return HashOf<SHA1CryptoServiceProvider>(text, enc);
        }

        public static string SHA384Of(string text)
        {
            return SHA384Of(text, Encoding.Default);
        }
        public static string SHA384Of(string text, Encoding enc)
        {
            return HashOf<SHA384CryptoServiceProvider>(text, enc);
        }

        public static string SHA512Of(string text)
        {
            return SHA512Of(text, Encoding.Default);
        }
        public static string SHA512Of(string text, Encoding enc)
        {
            return HashOf<SHA512CryptoServiceProvider>(text, enc);
        }

        public static string SHA256Of(string text)
        {
            return SHA256Of(text, Encoding.Default);
        }
        public static string SHA256Of(string text, Encoding enc)
        {
            return HashOf<SHA256CryptoServiceProvider>(text, enc);
        }

        public static string HashOf<TP>(string text, Encoding enc)
            where TP : HashAlgorithm, new()
        {
            var buffer = enc.GetBytes(text);
            var provider = new TP();
            return BitConverter.ToString(provider.ComputeHash(buffer)).Replace("-", "");
        }
    }
谢谢~ 非常感谢~
qq_30440553 2017-03-10
  • 打赏
  • 举报
回复
引用 7 楼 hanjun0612 的回复:
[quote=引用 5 楼 qq_30440553 的回复:] [quote=引用 3 楼 hanjun0612 的回复:] 你有先引用这个dll吗?
怎么引用...新手 抱歉 [/quote] 到别人的项目中 把 md5helper这个类复制到你的项目。 [/quote] 谢谢~ 谢谢~ 明白了 找到了 非常感谢
  • 打赏
  • 举报
回复
Md5Helper是别人封装的代码,给你一个差不多的封装代码
    public class Digest
    {
        public static string MD5Of(string text)
        {
            return MD5Of(text, Encoding.Default);
        }
        public static string MD5Of(string text, Encoding enc)
        {
            return HashOf<MD5CryptoServiceProvider>(text, enc);
        }
        public static string SHA1Of(string text)
        {
            return SHA1Of(text, Encoding.Default);
        }
        public static string SHA1Of(string text, Encoding enc)
        {
            return HashOf<SHA1CryptoServiceProvider>(text, enc);
        }

        public static string SHA384Of(string text)
        {
            return SHA384Of(text, Encoding.Default);
        }
        public static string SHA384Of(string text, Encoding enc)
        {
            return HashOf<SHA384CryptoServiceProvider>(text, enc);
        }

        public static string SHA512Of(string text)
        {
            return SHA512Of(text, Encoding.Default);
        }
        public static string SHA512Of(string text, Encoding enc)
        {
            return HashOf<SHA512CryptoServiceProvider>(text, enc);
        }

        public static string SHA256Of(string text)
        {
            return SHA256Of(text, Encoding.Default);
        }
        public static string SHA256Of(string text, Encoding enc)
        {
            return HashOf<SHA256CryptoServiceProvider>(text, enc);
        }

        public static string HashOf<TP>(string text, Encoding enc)
            where TP : HashAlgorithm, new()
        {
            var buffer = enc.GetBytes(text);
            var provider = new TP();
            return BitConverter.ToString(provider.ComputeHash(buffer)).Replace("-", "");
        }
    }
正怒月神 2017-03-10
  • 打赏
  • 举报
回复
引用 5 楼 qq_30440553 的回复:
[quote=引用 3 楼 hanjun0612 的回复:] 你有先引用这个dll吗?
怎么引用...新手 抱歉 [/quote] 到别人的项目中 把 md5helper这个类复制到你的项目。
巴士上的邂逅 2017-03-10
  • 打赏
  • 举报
回复
VS中输入System.Security.Cryptography.MD5,然后F1
qq_30440553 2017-03-10
  • 打赏
  • 举报
回复
引用 3 楼 hanjun0612 的回复:
你有先引用这个dll吗?
怎么引用...新手 抱歉
qq_30440553 2017-03-10
  • 打赏
  • 举报
回复
引用 2 楼 yuankaiwsl 的回复:
你说的是Md5Helper吗,这个是你从哪里复制过来的?
我是看别人视频 看来的 ...发行我用不了
正怒月神 2017-03-10
  • 打赏
  • 举报
回复
你有先引用这个dll吗?
巴士上的邂逅 2017-03-10
  • 打赏
  • 举报
回复
你说的是Md5Helper吗,这个是你从哪里复制过来的?
qq_30440553 2017-03-10
  • 打赏
  • 举报
回复
没法引用命名空间

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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