当前位置:首页 » 密码管理 » netmd5加密

netmd5加密

发布时间: 2024-06-04 03:53:05

㈠ .net(md5)加密汉字的结果与java(md5)加密汉字的结果不一样。。。

肯定是一样的。这个无论哪种语言获得的加密结果也是一样的。如果不一样有以下几种可能:
1.加密返回的位数不一样,因为有的md5加密可以返回16位或32位结果。
2.是否汉字在处理的时候有被代码变成了其它的编码。.net一般不会变编码的,而java根据操作系统不同,有可能在内部转了编码的。

㈡ ASP.NET实现对输入的密码用MD5+盐,并加密

public partial class _Default : System.Web.UI.Page
{
public bool IsMd5
{
get
{
//添加命名空间 using System.Configuration;
return ConfigurationManager.AppSettings["Md5"] == "1";
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (IsMd5)
{
//添加命名空间 using System.Web.Security;
string MD5 = FormsAuthentication.("被加密的字段", "MD5"); // SHA1 MD5
}
}
}
---------------------web.config----------------------------------
<appSettings>
<!--加密, 1:代表是; 0:代表不是-->
<add key="Md5" value="1"/>
</appSettings>

㈢ 求VB.NET的MD5算法调用

下面是完整的类,可以设置任意密码

'DES及md5加密解密----添加引用中添加对system.web的引用。
ImportsSystem.Security.Cryptography
ImportsSystem
ImportsSystem.Text
ImportsSystem.Web
'''<summary>
'''DES加密类
'''</summary>
'''<remarks></remarks>
PublicClassDESEncrypt
PublicSubDESEncrypt()
EndSub
PublicSharedFunctionEncrypt(ByValTextAsString)AsString
ReturnEncrypt(Text,"12345678")
EndFunction
PublicSharedFunctionEncrypt(ByValTextAsString,ByValsKeyAsString)AsString
()
DiminputByteArrayAsByte()
inputByteArray=Encoding.Default.GetBytes(Text)
des.Key=ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.(sKey,"md5").Substring(0,8))
des.IV=ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.(sKey,"md5").Substring(0,8))
DimmsAsNewSystem.IO.MemoryStream()
DimcsAsNewCryptoStream(ms,des.CreateEncryptor(),CryptoStreamMode.Write)
cs.Write(inputByteArray,0,inputByteArray.Length)
cs.FlushFinalBlock()
DimretAsNewStringBuilder()
DimbAsByte
ForEachbInms.ToArray()
ret.AppendFormat("{0:X2}",b)
Next
Returnret.ToString()
EndFunction
PublicSharedFunctionDecrypt(ByValTextAsString)AsString
ReturnDecrypt(Text,"12345678")
EndFunction
PublicSharedFunctionDecrypt(ByValTextAsString,ByValsKeyAsString)AsString
()
DimlenAsInteger
len=Text.Length/2
DiminputByteArray(len-1)AsByte
Dimx,iAsInteger
Forx=0Tolen-1
i=Convert.ToInt32(Text.Substring(x*2,2),16)
inputByteArray(x)=CType(i,Byte)
Next
des.Key=ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.(sKey,"md5").Substring(0,8))
des.IV=ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.(sKey,"md5").Substring(0,8))
DimmsAsNewSystem.IO.MemoryStream()
DimcsAsNewCryptoStream(ms,des.CreateDecryptor(),CryptoStreamMode.Write)
cs.Write(inputByteArray,0,inputByteArray.Length)
cs.FlushFinalBlock()
ReturnEncoding.Default.GetString(ms.ToArray())
EndFunction
EndClass
'以下是调用方法
PublicClassForm1
PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Click'加密
Dimstr_EncryptAsString=DESEncrypt.Encrypt("你要加密的文本,可以是任意长度","密码,可以很长,如果省略这个参数就是默认的12345678")
EndSub
PrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.Click'解密
Dimstr_DecryptAsString=DESEncrypt.Decrypt("你要解密的文本,可以是任意长度","加密时用到的密码,如果省略这个参数就是默认的12345678")
EndSub
热点内容
编译预处理时打印宏的值 发布:2025-09-14 17:11:53 浏览:61
linuxvim插件 发布:2025-09-14 17:11:04 浏览:941
linux导航 发布:2025-09-14 17:08:57 浏览:501
问道登陆器源码 发布:2025-09-14 17:08:01 浏览:904
为什么安卓手机总是提示软件停运 发布:2025-09-14 17:01:27 浏览:962
破解exe加密视频软件 发布:2025-09-14 16:44:18 浏览:279
29乘法手指速算法 发布:2025-09-14 16:11:30 浏览:836
iosandroidhtml5 发布:2025-09-14 16:10:39 浏览:931
systemuiapk反编译 发布:2025-09-14 15:46:44 浏览:999
php本地安装 发布:2025-09-14 15:44:59 浏览:352