您的位置: 首页 - Md5
  • 本站大部分内容从网上收集,收集目的仅供研究、学习。涉及版权或不希望收录您的文章请您及时与我联系。
  • 本站IM群,请自行选择。请各位朋友按照自己喜好加入。加入群后请及时发言,防止被清理。谢谢您的合作!!!
  • QQ群:Y①WEB开发(ASP.NET)号码:7351660 QQ群:Y②WEB开发(ASP+.NET)号码:11864905
  • QQ群:Y③WEB开发(DIV+CSS)号码:16610506 QQ群:Y④WEB开发(JS+AJAX)号码:16143998
  • QQ群:Y⑤WEB开发(新手)号码:12777715 MSN群:yaosansi[at]126.com

ASP.Net中MD5和SHA1加密的几种方法

分类: C#|DOTNET 发布: yaosansi 浏览: 日期: 2007年9月6日

首先简单介绍一下MD5SHA1:

 


MD5的全称是Message-Digest Algorithm 5(信息-摘要算法),在90年代初由Mit Laboratory for Computer ScienceRsa data security incRonald l. rivest开发出来,经md2md3md4发展而来。它的作用是让大容量信息在用数字签名软件签署私人密匙前被"压缩"成一种保密的格式(就是把一个任意长度的字节串变换成一定长的大整数)。不管是md2md4还是md5,它们都需要获得一个随机长度的信息并产生一个128位的信息摘要。

 

加密哈希函数将任意长度的二进制字符串映射为固定长度的小型二进制字符串。加密哈希函数有这样一个属性:在计算上不大可能找到散列为相同的值的两个不同的输入;也就是说,两组数据的哈希值仅在对应的数据也匹配时才会匹配。数据的少量更改会在哈希值中产生不可预知的大量更改。所以你很难从加密后的文字中找到蛛丝马迹。

 


 

SHA1的全称是Secure Hash Algorithm(安全哈希算法)

c#获取文件md5值

分类: C#|DOTNET 发布: yaosansi 浏览: 日期: 2007年8月26日

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace MyHash
{
        class md5
    {
        /// <summary>
        /// 实现对一个文件md5的读取,path为文件路径
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public string md5_hash(string path)
        {
            try
            {
                FileStream get_file = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
                System.Security.Cryptography.MD5CryptoServiceProvider get_md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
                byte[] hash_byte = get_md5.ComputeHash(get_file);
                string resule = System.BitConverter.ToString(hash_byte);
                resule = resule.Replace("-", "");
                return resule;
            }
            catch (Exception e)
            {
               
                return e.ToString();
 
            }
         
          
 
        }
    }
}
 
 
 
 
 
 
===================================================
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Security.Cryptography;
 
 
 public static void getFileMD5(string path)
        {
            FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            byte[] md5byte = md5.ComputeHash(fs);
            int i, j;
            foreach (byte b in md5byte)
            {
                i = Convert.ToInt32(b);
                j = i >> 4;
                Console.Write(Convert.ToString(j, 16));
                j = ((i << 4) & 0x00ff) >> 4;
                Console.Write(Convert.ToString(j, 16));
            }
            Console.ReadLine();

        }
 
 
 
 
 
 
 

非常流行的javascript的md5加密

分类: JavaScript 发布: yaosansi 浏览: 日期: 2006年9月19日

非常流行的javascript的md5加密

纠正:HashPasswordForStoringInConfigFile中的Md5算法并非常用的M

分类: C#|DOTNET 发布: yaosansi 浏览: 日期: 2006年1月17日

本来我也以为System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile中的MD5和常用的一样

可今天一试,结果有很大不同,
比如test,HashPasswordForStoringInConfigFile编码成
C8059E2EC7419F590E79D7F1B774BFE6
分页:[«]1[»]

Powered By Z-Blog 1.8 Walle Build 100427

UNISON UPDATE Copyright 2005-2010 yaosansi'site All Rights Reserved.
感谢系统大玩家为本站提供FTP空间
辽ICP备05021434号