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 ...
随机推荐
- Unity Meshes
1. Unity 没有自带建模工具 2. 导入 Mesh 时,Unity 会自动寻找所引用的纹理,查找文件夹名为 Textures 的.先在本目录下找 -> 上溯在parent查找 ==> ...
- Intel指令集专有词解释
SSE 概述 SSE(Streaming SIMD Extensions)是英特尔在AMD的3D Now!发布一年之后,在其计算机芯片Pentium III中引入的指令集,是MMX的超集.AMD后来在 ...
- 怎么用ABBYY打开PDF文档
我们日常工作中接触的文档大多都是PDF格式的,这种格式的文件需要借助工具才能打开,大家最熟悉的无非就是Adobe了,但你知道吗?除了Adobe,OCR文字识别软件也可以打开PDF文档,比如ABBYY ...
- Response.Redirect在新窗口打开网页
来自:http://www.woosky.net/show.asp?id=761 Respose.Write("<script language='javascript'>win ...
- Linux How to add a new disk to LVM
转自:http://blog.itpub.net/7191998/viewspace-772060/ 1.check old diskspace and device listdf -halfree ...
- 15条变量&方法命名的最佳实践【转】
原文地址:15 Best Practices of Variable & Method Naming 不同的代码段采用不同的命名长度.通常来说,循环计数器(loop counters)采用1位 ...
- android 完全退出应用程序(重要)
android退出应用程序会调用android.os.Process.killProcess(android.os.Process.myPid())或是System.exit(0),这只是针对第一个A ...
- bootstrap3-typeahead 自动补全
很酷的一个自动补全插件 http://twitter.github.io/typeahead.js 在bootstrap中使用typeahead插件,完成自动补全 相关的文档:https://gith ...
- Js RegExp对象
1 语法 1.1 直接量语法 /pattern/attributes 1.2 创建RegExp对象 new RegExp(pattern, attributes) 1.3 说明 pattern是正则表 ...
- <新手必读>Eclipse中,Add Jars与Add Library的区别
Eclipse中,工程属性的Java Build Path的Library标签页下,有如下几个按钮:Add Jars...添加JAR包,是指本Eclipse当前包含的工程中的,在工程列表下选取即可Ad ...