国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

.NET中帶有口令加密的注冊頁面(還是發(fā)表在這里吧~-~)

2024-07-10 12:58:36
字體:
供稿:網(wǎng)友
在asp.net中提供了加密的功能。名字空間system.web.security中包含了類formsauthentication,其中有一個方法hashpasswordforstoringinconfigfile。這個方法可以將用戶提供的字符變成亂碼,然后存儲起來。注意此方法是不能繼承的。
下面的代碼就是在做注冊頁面時將數(shù)據(jù)加密后存儲到數(shù)據(jù)庫的過程
imports system.web.security
imports system.data
imports system.data.sqlclient  '////////所需要的名稱空間

private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click
        dim passformate as string
        '///////////////encryptpassword調(diào)用函數(shù)
        passformate = encryptpassword(uid.text, "md5")   '//////////或者是encryptpassword(uid.text, "sha1")
        'textbox2.text = encryptpassword(uid.text, "md5")
        'textbox3.text = encryptpassword(uid.text, "sha1")
        '///////////這些大家自己試驗吧
        'textbox4.text = formsauthentication.formscookiename
        'textbox5.text = formsauthentication.formscookiepath
        'textbox6.text = formsauthentication.getredirecturl(uid.text, true)
        'formsauthentication.setauthcookie(uid.text, true)

        dim sql as string = "insert into pwd(uid,pwd) values(@uid,@pwd)"
        dim comm as sqlcommand = new sqlcommand(sql, conn)
        conn.open()
        comm.parameters.add(new sqlparameter("@uid", sqldbtype.char, 16))
        comm.parameters("@uid").value = uid.text
        comm.parameters.add(new sqlparameter("@pwd", sqldbtype.char, 16))
        comm.parameters("@pwd").value = passformate
        comm.executenonquery()
        
    end sub

    '////////////////定義加密函數(shù),可以隨時調(diào)用。
    function encryptpassword(byval password as string, byval passwordformate as string)
        if passwordformate = "sha1" then
            encryptpassword = formsauthentication.hashpasswordforstoringinconfigfile(password, "sha1")
        elseif passwordformate = "md5" then
            encryptpassword = formsauthentication.hashpasswordforstoringinconfigfile(password, "md5")
        else
            encryptpassword = ""
        end if

    end function
至于用戶的驗證也是一樣的思路了。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 岳普湖县| 上思县| 宜都市| 句容市| 鄂伦春自治旗| 赤壁市| 奉新县| 龙山县| 皋兰县| 江西省| 卢氏县| 镇原县| 夹江县| 封开县| 区。| 武城县| 浦城县| 丽水市| 汕头市| 和静县| 宁阳县| 凤阳县| 重庆市| 聂拉木县| 碌曲县| 赞皇县| 巴林左旗| 双鸭山市| 化州市| 沙坪坝区| 定南县| 双柏县| 大厂| 涿州市| 修武县| 巴林左旗| 唐山市| 攀枝花市| 呼伦贝尔市| 平定县| 景泰县|