Bogart SysPwd.vb
Module syspwd Public Const STR_MASK = "MyFunction" '加密用字串
Public Const INT_PWD_LENGTH = '預定義密碼長度
Public GintCheckPwd As Integer
'當傳入的密碼長度大於預定義密碼長度時
'將?生一個Message Box
'以下兩個常量是該Message Box中的具體提示資訊和標題欄中的文字
Public Const STR_PWD_ERROR = "The length of password can not be greater than 10 characters !"
Public Const STR_SYSTEM_NAME = "Bogart Report System" Public Const STR_INVALID_USER = "Password is not valid !"
Public Const STR_CHANGE_PASSWORD_ERROR = "User ID is not valid !" '以下的變數的定義在正式使用時去掉 '該函數的作用是將傳入的密碼字串轉換成加密的密碼字串
'傳入的字串是用戶輸入的未經過系統加密的密碼
'傳出的資料類型是字串型,?經過系統加密後的密碼 Public Function EnPwd(ByVal strIn As String) As String
Dim intCount As Integer
Dim intPwdWord() As Integer
Dim intTemp As Integer
Dim strColumn1 As String
Dim strColumn2 As String
Dim strColumn3 As String
Dim strTemp As String
Dim intDivTemp As Integer strColumn1 = ""
strColumn2 = ""
strColumn3 = ""
intTemp =
strTemp = ""
intDivTemp = If Len(strIn) > INT_PWD_LENGTH Then
MsgBox(STR_PWD_ERROR, , STR_SYSTEM_NAME)
EnPwd = ""
Exit Function
End If
ReDim intPwdWord(INT_PWD_LENGTH) For intCount = To INT_PWD_LENGTH
If Len(STR_MASK) < INT_PWD_LENGTH Then
intTemp = intTemp +
If intTemp > Len(STR_MASK) Then
intTemp =
End If
intPwdWord(intCount) = Asc(Mid(STR_MASK, intTemp, ))
Else
intPwdWord(intCount) = Asc(Mid(STR_MASK, intCount, ))
End If
Next
For intCount = To Len(strIn)
intTemp = Asc(Mid(strIn, intCount, ))
intDivTemp = intDivTemp +
If intDivTemp > Then
intDivTemp =
End If
intTemp = intTemp * intDivTemp
intPwdWord(intCount) = intPwdWord(intCount) + intTemp
Next
For intCount = To INT_PWD_LENGTH
strTemp = CStr(intPwdWord(intCount))
If Len(strTemp) < Then
strTemp = StrDup( - Len(strTemp), "") & strTemp
End If
strColumn1 = strColumn1 & Mid(strTemp, , )
strColumn2 = strColumn2 & Mid(strTemp, , )
strColumn3 = strColumn3 & Mid(strTemp, , )
Next
EnPwd = strColumn1 & strColumn2 & strColumn3 End Function '該函數的作用是將傳入的加密的密碼字串轉換成不加密的密碼字串
'傳入的字串是經過系統加密後的密碼
'傳出的資料類型是字串型,?未經過系統加密的密碼 Public Function DePwd(ByVal strIn As String) As String
Dim intCount As Integer
Dim intTemp As Integer
Dim strTemp As String
Dim strColumn1 As String
Dim strColumn2 As String
Dim strColumn3 As String
Dim intPwdWord() As Integer
Dim intDivTemp As Integer DePwd = ""
strColumn1 = ""
strColumn2 = ""
strColumn3 = ""
intTemp =
strTemp = ""
intDivTemp = strColumn1 = Mid(strIn, , INT_PWD_LENGTH)
strColumn2 = Mid(strIn, INT_PWD_LENGTH + , INT_PWD_LENGTH)
strColumn3 = Mid(strIn, INT_PWD_LENGTH * + , INT_PWD_LENGTH)
strTemp = ""
For intCount = To INT_PWD_LENGTH
strTemp = strTemp & Mid(strColumn1, intCount, )
strTemp = strTemp & Mid(strColumn2, intCount, )
strTemp = strTemp & Mid(strColumn3, intCount, )
Next
ReDim intPwdWord(INT_PWD_LENGTH)
For intCount = To INT_PWD_LENGTH intPwdWord(intCount) = Val(Mid(strTemp, intCount * - , ))
If Len(STR_MASK) < INT_PWD_LENGTH Then
intTemp = intTemp +
If intTemp > Len(STR_MASK) Then
intTemp =
End If
intPwdWord(intCount) = intPwdWord(intCount) - Asc(Mid(STR_MASK, intTemp, ))
Else
intPwdWord(intCount) = intPwdWord(intCount) - Asc(Mid(STR_MASK, intCount, ))
End If
intDivTemp = intDivTemp +
If intDivTemp > Then
intDivTemp =
End If
intPwdWord(intCount) = intPwdWord(intCount) / intDivTemp
If intPwdWord(intCount) <> Then
DePwd = DePwd & Chr(intPwdWord(intCount)) End If
Next End Function '以下函數?檢查密碼是否有效
'傳入的第一個參數?用戶名,第二個是密碼(未加密)
'如果密碼正確,則返回True
'如果密碼不正確或該用戶不存在,則出現MsgBox後返回False
Public Function CheckPwd(ByVal strUser As String, ByVal strPassword As String) As Boolean
GintCheckPwd = GintCheckPwd +
Dim Rs As New ADODB.Recordset
Dim strSQLStmt As String CheckPwd = False
On Error GoTo DBError
If adoConn.State <> ConnectionState.Open Then
adoConn.Open()
End If strSQLStmt = "SELECT Password FROM " & g.gRptdev & "g_userid WHERE UserID='" & strUser & "'" '以下的dbconn應該改寫成統一的連庫
Rs.Open(strSQLStmt, adoConn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
If Rs.Fields().Value <> EnPwd(strPassword.ToUpper) Then
MsgBox(STR_INVALID_USER, vbCritical, STR_SYSTEM_NAME)
'If GintCheckPwd = 3 Then
' MsgBox("您已經三次登陸失敗,系統將退出", vbExclamation, STR_SYSTEM_NAME)
'End If
Exit Function
End If CheckPwd = True Exit Function
DBError:
MsgBox(STR_INVALID_USER, vbExclamation, STR_SYSTEM_NAME)
End Function '以下函數?檢查密碼是否有效
'傳入的第一個參數?用戶名,第二個是新密碼(未加密)
'如果更改成功,則返回True
'如果更改不成功(可能因?用戶不存在等原因),則出現MsgBox後返回False
Public Function ChangePwd(ByVal strUser As String, ByVal strPassword As String) As Boolean
Dim Rs As ADODB.Recordset
Dim strSQLStmt As String ChangePwd = False
On Error GoTo DBError
adoConn.BeginTrans()
strSQLStmt = "SELECT Password FROM " & g.gRptdev & "g_userid WHERE UserID='" & strUser & "'" '以下的dbconn應該改寫成統一的連庫
Rs = adoConn.Execute(strSQLStmt)
If Rs.EOF Then
MsgBox(STR_CHANGE_PASSWORD_ERROR, , STR_SYSTEM_NAME)
Rs.Close()
adoConn.RollbackTrans()
Exit Function
End If
Rs.Close()
strSQLStmt = "UPDATE " & g.gRptdev & "g_userid SET Password = '" & EnPwd(strPassword.ToUpper) & "' WHERE UserID='" & strUser & "'" adoConn.Execute(strSQLStmt)
adoConn.CommitTrans()
ChangePwd = True
Exit Function
DBError:
MsgBox(STR_CHANGE_PASSWORD_ERROR, , STR_SYSTEM_NAME)
adoConn.RollbackTrans()
End Function
End Module
Bogart SysPwd.vb的更多相关文章
- Bogart BogartPublic.vb
Imports System.Data.SqlClient Imports System.Data #Region "IBogartToolbar,請勿隨便更改" Interfac ...
- Bogart gSub.vb
'--------------Job No 0900408 -------------- '--DIM PART ONE ONLINE Update Order Qty '''主要新加過程名 Refr ...
- Bogart gData.vb
Imports System Imports System.Data Imports System.Data.OleDb Imports Microsoft.VisualBasic Imports S ...
- Bogart BogartAutoCode.vb
Imports System.Data.SqlClient Imports System.Data Public Class BogartAutoCodeDataBase Private Conn A ...
- Bogart gFunction.vb
Module gFunction '其它不是常用的方法及函數 #Region " 將指定的數據格式轉換為英文格式" Public Function EnglishFormat(By ...
- Bogart gGrid.vb
Namespace BogartMis.Cls Public Class gGrid '設定表格控的列標題的別名 '說明:strItem字符串的格式為"01,02,03,04,05" ...
- [转载]C#中MessageBox.Show用法以及VB.NET中MsgBox用法
一.C#中MessageBox.Show用法 MessageBox.Show (String) 显示具有指定文本的消息框. 由 .NET Compact Framework 支持. MessageBo ...
- VB.NET设置控件和窗体的显示级别
前言:在用VB.NET开发射频检测系统ADS时,当激活已存在的目标MDI子窗体时,被其他子窗体遮住了,导致目标MDI子窗体不能显示. 这个问题怎么解决呢?网上看到一篇帖子VB.NET设置控件和窗体的显 ...
- 用VB脚本批到导入字段到PowerDesigner
在PowerDesigner使用脚本批量导入excel中记录的表结构信息,由于需要通过powerdesigner逆向工程创建一些sybase IQ的表,由于是接口数据,只有excel表,手动导入太耗时 ...
随机推荐
- MyEclipse junit测试问题initializationError
问题的情况如上. 问题的解决方法居然是:选中函数的整行,而不是只选中函数名,如下图选中运行junit测试. TestMySQL.testDriverMannager1Unrooted Testsini ...
- PyCharm:ModuleNotFoundError: No module named 'HTMLTestRunner'
PyCharm找不到HTMLTestRunner,还是之前的原因PyCharm和之前命令行安装使用的不是一套资源,需要重新导入 查看旧HTMLTestRunner的路径 在PyCharm找到同样类似的 ...
- HDU1070:Milk
Milk Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- HTML5和CSS3阶段,我是如何学习的?
经过一个月的学习,我收获了许多,今天的测验是做一个企业中文网站,令我自己感到吃惊的是,我前前后后用了4个小时就完成了,这在一个月前根本不可能,因为对布局属性的理解还不够深刻,常常会在调试中浪费大量时间 ...
- 水题 不要62 HDU 2089
先预处理出所有的数是不是可能拿来用,我的想法是记录1-i这个区间内可用的数为s[i]. 输入a,b.答案就为s[b] - s[a-1]. 贴代码: #include<cstdio> #de ...
- War Chess bfs+优先队列
War chess is hh's favorite game: In this game, there is an N * M battle map, and every player has hi ...
- JS Array.filter()方法
1.filter()接收的函数可以有多个参数.通常我们只使用第一个参数,第二参数和第三个参数表示元素的位置和数组本身: //去重 var arr = ["1", "2&q ...
- Microsoft-Excel Sheet Column Number
Given a column title as appear in an Excel sheet, return its corresponding column number. For exampl ...
- https://wenku.baidu.com/view/35c88b375acfa1c7aa00ccca.html--swot
https://wenku.baidu.com/view/35c88b375acfa1c7aa00ccca.html
- Vault 0.10包含了web ui
Vault 是一个很不错的访问控制,secret api key 管理工具 新的0.10 有好多新的功能的添加,最棒的是有一个web ui 了 包含的新特性如下: K/V Secrets Engine ...