當前位置:首頁 » 密碼管理 » 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
熱點內容
雙線伺服器一個ip有什麼區別 發布:2025-10-15 02:35:14 瀏覽:757
php的類定義 發布:2025-10-15 02:27:46 瀏覽:505
編譯技術都是什麼 發布:2025-10-15 02:27:10 瀏覽:766
android卡片效果圖 發布:2025-10-15 02:26:18 瀏覽:686
申請郵箱密碼是什麼 發布:2025-10-15 02:23:15 瀏覽:546
Python轉換整形 發布:2025-10-15 02:18:32 瀏覽:794
維綸EBpro反編譯 發布:2025-10-15 02:10:42 瀏覽:85
軸承查詢源碼 發布:2025-10-15 01:58:24 瀏覽:795
linux系統里檢查ftp狀態 發布:2025-10-15 01:52:41 瀏覽:239
安卓手機底層數據在哪裡 發布:2025-10-15 01:22:43 瀏覽:468