十年網(wǎng)站開發(fā)經(jīng)驗 + 多家企業(yè)客戶 + 靠譜的建站團隊
量身定制 + 運營維護+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
這篇文章主要介紹“怎么用哈希算法實現(xiàn)ASP.NET數(shù)據(jù)加密”,在日常操作中,相信很多人在怎么用哈希算法實現(xiàn)ASP.NET數(shù)據(jù)加密問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”怎么用哈希算法實現(xiàn)ASP.NET數(shù)據(jù)加密”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
創(chuàng)新新互聯(lián),憑借十載的網(wǎng)站設計、成都做網(wǎng)站經(jīng)驗,本著真心·誠心服務的企業(yè)理念服務于成都中小企業(yè)設計網(wǎng)站有1000+案例。做網(wǎng)站建設,選成都創(chuàng)新互聯(lián)。
哈希算法實現(xiàn)ASP.NET數(shù)據(jù)加密的過程是什么呢?來開始我們的講述:
以下是用C#實現(xiàn)的哈希加密,大家可以根據(jù)自己的需要更改所需的算法,文中以SHA1為例:
using System; using System.IO; using System.Security.Cryptography; using System.Text; namespace DataCrypto { /// ﹤summary﹥ /// 實現(xiàn)ASP.NET數(shù)據(jù)加密哈希加密類 /// ﹤/summary﹥ public class HashMethod { private HashAlgorithm HashCryptoService; /// ﹤summary﹥ /// 實現(xiàn)ASP.NET數(shù)據(jù)加密哈希加密類的構(gòu)造函數(shù) /// ﹤/summary﹥ public HashMethod() { HashCryptoService = new SHA1Managed(); } /// ﹤summary﹥ /// 實現(xiàn)ASP.NET數(shù)據(jù)加密加密方法 /// ﹤/summary﹥ /// ﹤param name="Source"﹥待加密的串﹤/param﹥ /// ﹤returns﹥經(jīng)過加密的串﹤/returns﹥ public string Encrypto(string Source) { byte[] bytIn = UTF8Encoding.UTF8.GetBytes(Source); byte[] bytOut = HashCryptoService.ComputeHash(bytIn); return Convert.ToBase64String(bytOut); } } }
到此,關于“怎么用哈希算法實現(xiàn)ASP.NET數(shù)據(jù)加密”的學習就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關知識,請繼續(xù)關注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
分享文章:怎么用哈希算法實現(xiàn)ASP.NET數(shù)據(jù)加密
轉(zhuǎn)載來源:http://m.jiaotiyi.com/article/jhjjoh.html