code md5
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Security.Cryptography;
- using System.Text;
- using System.Web;
- using NLog;
- namespace services.Resources
- {
- public class MD5Util
- {
- private static Logger logger = LogManager.GetCurrentClassLogger();
- public static string GetMd5Hash(string input)
- {
- // Create a new Stringbuilder to collect the bytes
- // and create a string.
- StringBuilder sBuilder = new StringBuilder();
- using (MD5 md5Hash = MD5.Create())
- {
- // Convert the input string to a byte array and compute the hash.
- byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
- // Loop through each byte of the hashed data
- // and format each one as a hexadecimal string.
- for (int i = ; i < data.Length; i++)
- {
- sBuilder.Append(data[i].ToString("x2"));
- }
- }
- // Return the hexadecimal string.
- logger.Debug(sBuilder.ToString());
- return sBuilder.ToString();
- }
- // Verify a hash against a string.
- public static bool VerifyMd5Hash(string input, string hash)
- {
- // Hash the input.
- string hashOfInput = GetMd5Hash(input);
- // Create a StringComparer an compare the hashes.
- StringComparer comparer = StringComparer.OrdinalIgnoreCase;
- if ( == comparer.Compare(hashOfInput, hash))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- }
code md5的更多相关文章
- iOS开发 - 网络数据安全加密(MD5)
提交用户的隐私数据 一定要使用POST请求提交用户的隐私数据GET请求的所有参数都直接暴露在URL中请求的URL一般会记录在服务器的访问日志中服务器的访问日志是黑客攻击的重点对象之一 用户的隐私数据登 ...
- JQuery - MD5加密
效果: JS代码: 命名为任意名称,一般为:Jquery.md5.js /** * jQuery MD5 hash algorithm function * * <code> * Calc ...
- jQuery的md5加密插件及其它js md5加密代码
/** * jQuery MD5 hash algorithm function * * <code> * Calculate the md5 hash of a String * Str ...
- jquery MD5
/** * jQuery MD5 hash algorithm function * * <code> * Calculate the md5 hash of a String * Str ...
- 【javascript类库】zepto和jquery的md5加密插件
[javascript类库]zepto和jquery的md5加密插件 相信很多人对jQuery并不陌生,这款封装良好的插件被很多开发者使用. zepto可以说是jQuery在移动端的替代产品,它比jQ ...
- JavaScript-Tool:jquery.md5.js
ylbtech-JavaScript-Tool:jquery.md5.js 1.返回顶部 1. 引入js后 使用方法:document.write($.md5('1234')); 加密结果:81dc9 ...
- MD5加密处理
无论传送过程和存储方式,都是以明文的方式,很不安全!一旦泄漏,将会造成很大的损失! 插件名称jQuery.MD5.js: /** * jQuery MD5 hash algorithm functio ...
- 前端加密MD5
今天接触了MD5加密方式,记录一下使用方法,又去搜了搜关于MD5的详细内容 MD5在vue中使用方法 1.下载MD5模块 cnpm install md5 -S 2.引入模块 const md5 = ...
- 如何对数据进行MD5加密
前端进行加密 /** * jQuery MD5 hash algorithm function * * <code> * Calculate the md5 hash of a Strin ...
随机推荐
- UIview 学习与自定义--ios
UIView *view1=[[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)]; view1.backgroundColor=[UI ...
- C# Timer用法及实例详解
C# Timer用法有哪些呢?我们在使用C# Timer时都会有自己的一些总结,那么这里向你介绍3种方法,希望对你了解和学习C# Timer使用的方法有所帮助. 关于C# Timer类 在C#里关于 ...
- SignalR的安装
介绍 SignalR 是 ASP.NET 团队正在开发的一个 Microsoft .NET Framework 库和 jQuery 插件,可能包括在以后版本的 ASP.NET 平台中. 它提供了一些前 ...
- JavaScript对SVG进行操作的相关技术
原文地址:http://www.ibm.com/developerworks/cn/xml/x-svgscript/ 本文主要介绍在 SVG 中通过编程实现动态操作 SVG 图像的知识. SVG ...
- mysql 索引过长1071-max key length is 767 byte
问题 create table: Specified key was too long; max key length is 767 bytes 原因 数据库表采用utf8编码,其中varchar ...
- Q5: Remove Duplicates from Sorted Array
问题描述: Given a sorted array, remove the duplicates in place such that each element appear only once a ...
- 常用邮件 smtp pop
常用的邮箱服务器(SMTP.POP3)地址.端口 sina.com: POP3服务器地址:pop3.sina.com.cn(端口:110) SMTP服务器地址:smtp.sina.com.cn(端口 ...
- 运用cookie登陆人人网爬取数据
浏览器访问WEB服务器的过程 在用户访问网页时,不论是通过URL输入域名或IP,还是点击链接,浏览器向WEB服务器发出了一个HTTP请求(Http Request),WEB服务器接收到客户端浏览器的请 ...
- 取消GridView/ListView item被点击时的效果
方法一,在控件被初始化的时候设置 ? 1 2 gridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); listView.setSelec ...
- presto访问 Azure blob storage
当集群使用Azure Blog Storage时,prestoDB无法获取返回结果,在此记录下 如下,hive里面的两个表,一个使用的是本地的hdfs,一个是使用 azure blob storage ...