當前位置:首頁 » 密碼管理 » 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