我在 vb.net 中有一个函数,它使用如下密码加密文本:
Public Class PROT
Shared Function EncryptWithPassword(Target As String, Password As String) As String
'Target is the given text
'Password is the password
Dim datas as string =""
'store the encrypted text and with password in datas and return it
Return datas
End Function
End Class
我在我的表单中使用这个函数:
Private Sub encryptbtn_Click(sender As Object, e As EventArgs) Handles encryptbtn.Click
Dim texttoencrypt As String = TextBox1.Text
Dim passwordtotext As String = passwordbox.Text
Dim enc As String = PROT.EncryptWithPassword(texttoencrypt, passwordtotext)
IO.File.WriteAllText("C:\Users\Ubaada\Documents\SAFE.txt", enc)
End Sub
当 Textbox1 中的文本长度小于 5000 时,代码仅将表单挂起 2 秒。但是当我用 100000 的长度尝试它时,它会挂起表单并且不再响应。它不应该在 40 秒内响应吗(因为 100000 是 5000 的 20 倍)。
我的问题是如何操作代码,使其不会挂起表单并使用长度为 100000 或更大的字符串。我听说过线程,但我认为我不能这样使用它:
Dim enc as string=Thread.Start(PROT.EncryptWithPassword(texttoencrypt, passwordtotext))