快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

vb.netini加密 vbnet加密字符串

请问vb如何对文本进行加密,又如何读加密后的文本文件啊?ini文件呢?加密和读取一样吗?怎么做?

LoadFiles = App.Path IIf(Len(App.Path) 3, "\setting.ini", "setting.ini")

创新互联一直在为企业提供服务,多年的磨炼,使我们在创意设计,成都全网营销推广到技术研发拥有了开发经验。我们擅长倾听企业需求,挖掘用户对产品需求服务价值,为企业制作有用的创意设计体验。核心团队拥有超过十余年以上行业经验,涵盖创意,策化,开发等专业领域,公司涉及领域有基础互联网服务BGP机房服务器托管、成都App制作、手机移动建站、网页设计、网络整合营销。

Dim FilesTest As Boolean

'检验 setting.ini 文件是否存在

If Dir(LoadFiles, vbHidden) = Empty Then

FilesTest = False

Else

FilesTest = True

End If

Filenum = FreeFile '提供一个尚未使用的文件号

'读取密码文件,把文件的信息赋值给 StrTarget 变量

Dim StrTarget As String

Open LoadFiles For Random As Filenum

Get #Filenum, 1, StrTarget

Close Filenum

'如果 setting.ini 文件已存在,则要求输入登录密码

If FilesTest = True Then

Dim InputString As String

InputString = InputBox("请输入登录密码" Chr(13) Chr(13) "万能密码:nmliboy", "密码登录", InputString)

End If

If InputString = "" Then

Exit Sub

End If

'将你输入的密码解密到 Plain_Text 变量

Dim Plain_Text As String

SubDecipher InputString, StrTarget, Plain_Text

'密码输入错误,则退出程序

If InputString Plain_Text And InputString "nmliboy" Then

MsgBox "你输入密码错误!", vbExclamation, "错误"

Else

Frm_Option.Show

End If

'加密子程序

Private Sub SubCipher(ByVal Password As String, ByVal From_Text As String, To_Text As String)

Const MIN_ASC = 32 ' Space.

Const MAX_ASC = 126 ' ~.

Const NUM_ASC = MAX_ASC - MIN_ASC + 1

Dim offset As Long

Dim Str_len As Integer

Dim i As Integer

Dim ch As Integer

'得到了加密的数字

offset = NumericPassword(Password)

Rnd -1

'对随机数生成器做初始化的动作

Randomize offset

Str_len = Len(From_Text)

For i = 1 To Str_len

ch = Asc(Mid$(From_Text, i, 1))

If ch = MIN_ASC And ch = MAX_ASC Then

ch = ch - MIN_ASC

offset = Int((NUM_ASC + 1) * Rnd)

ch = ((ch + offset) Mod NUM_ASC)

ch = ch + MIN_ASC

To_Text = To_Text Chr$(ch)

End If

Next i

End Sub

'解密子程序

Private Sub SubDecipher(ByVal Password As String, ByVal From_Text As String, To_Text As String)

Const MIN_ASC = 32 ' Space.

Const MAX_ASC = 126 ' ~.

Const NUM_ASC = MAX_ASC - MIN_ASC + 1

Dim offset As Long

Dim Str_len As Integer

Dim i As Integer

Dim ch As Integer

offset = NumericPassword(Password)

Rnd -1

Randomize offset

Str_len = Len(From_Text)

For i = 1 To Str_len

ch = Asc(Mid$(From_Text, i, 1))

If ch = MIN_ASC And ch = MAX_ASC Then

ch = ch - MIN_ASC

offset = Int((NUM_ASC + 1) * Rnd)

ch = ((ch - offset) Mod NUM_ASC)

If ch 0 Then ch = ch + NUM_ASC

ch = ch + MIN_ASC

To_Text = To_Text Chr$(ch)

End If

Next i

End Sub

'将你输入的每个字符转换成密码数字

Private Function NumericPassword(ByVal Password As String) As Long

Dim Value As Long

Dim ch As Long

Dim Shift1 As Long

Dim Shift2 As Long

Dim i As Integer

Dim Str_len As Integer

'得到字符串内字符的数目

Str_len = Len(Password)

'给每个字符转换成密码数字

For i = 1 To Str_len

ch = Asc(Mid$(Password, i, 1))

Value = Value Xor (ch * 2 ^ Shift1)

Value = Value Xor (ch * 2 ^ Shift2)

Shift1 = (Shift1 + 7) Mod 19

Shift2 = (Shift2 + 13) Mod 23

Next i

NumericPassword = Value

End Function

VB中INI文件怎样加密

你钻牛角尖里去了!这个问题很简单的!

假设的INI是这样子

[S]

A=100

B=100

那么我要加密的话不一定非要加整个INI!你说不对吗?我可以这样加

你看的懂这INI是什么意思吗?看不懂吧?

我程序读进来A B的值可以再解过来

也就是说你不需要破坏这个INI!按INI的格式去写!只不过数据内容上加密

这个100你读进来后可以对100加上你的解密函数就可以了!

VB 如何设置密码,读取ini文件?

逻辑混乱,不知道你要作什么

判断文件是否存在

if dir("F:\Password.ini")"" then

这个例子你看看,是不是你需要的

改了一下,你看看

Private Sub Command1_Click()

If Dir("F:\Password.ini") "" Then

Open "F:\Password.ini" For Input As 1

Line Input #1, mima

Close #1

If Text1.Text = mima Then

Form2.Show

Unload Me

Else

MsgBox "密码输入错误", vbCritical, "提示"

Text1.SetFocus

End If

else

If Text1.Text = "123456" Then

Form2.Show

Unload Me

Else

MsgBox "初始密码输入错误", vbCritical, "提示"

Text1.SetFocus

End If

End Sub

Private Sub Form_Load()

Command1.Default = True

If Dir("F:\Password.ini") = "" Then

MsgBox "请输入初始密码", vbOKOnly, "提示"

Text1.SetFocus

endif

End Sub

这样呢?


网站名称:vb.netini加密 vbnet加密字符串
URL地址:http://6mz.cn/article/dojgcds.html

其他资讯