關於VB的程式設計問題編,寫加密程式爆急啊

2022-02-11 07:15:08 字數 4717 閱讀 7336

1樓:匿名使用者

private sub command1_click()'用每個字母的ascii碼加7,相加之後的ascii碼值若超過90但不超過97,

'則減去10,若超過122,則減去8。

dim a, b as integer

a = asc(left(text1.text, 1)) + 7b = asc(right(text1.text, 1)) + 7if ((a > 90) and (a < 97)) thena = a - 10

elseif a > 122 then

a = a - 8

end if

if ((b > 90) and (b < 97)) thenb = b - 10

elseif a > 122 then

b = b - 8

end if

text2.text = chr(a) & chr(b)end sub

private sub form_load()'text1--輸入 text2--加密後輸出text1.maxlength = 2

text2.maxlength = 2

text1.text = ""

text2.text = ""

end sub

2樓:

假設:text1是wx所在文字框的名字(name),text2是tu所在文字框的名字(name),command1是「加密」按鈕的名字(name),那麼下面的**能幫你

private sub command1_click()

dim strtmp as string, bytleft as byte, bytright as byte

strtmp = text1.text

if len(strtmp) < 2 then exit sub

bytleft = asc(left(strtmp, 1)) + 7

bytright = asc(mid(strtmp, 2, 1)) + 7

if (bytleft >= 90) and (bytleft <= 98) then

bytleft = bytleft - 10

elseif bytleft > 122 then

bytleft = bytleft - 8

end if

if (bytright >= 90) and (bytright <= 98) then

bytright = bytright - 10

elseif bytright > 122 then

bytright = bytright - 8

end if

text2.text = chr(bytleft) & chr(bytright)

end sub

3樓:匿名使用者

我也現一下醜:

private sub command1_click()text2.text = ""

for i = 1 to len(text1.text)s = mid(text1.text, i, 1)t = asc(s) + 7

if t > 90 and t <= 97 then t = t - 10

if t > 122 then t = t - 8text2.text = text2.text & chr(t)next

end sub

vb中如何編寫乙個加密程式?

4樓:匿名使用者

還可以用api函式來呼叫出來加密!有個加密的演算法 在裡面!

5樓:匿名使用者

如把a加上乙個值可以變成b一樣的加密方法!

怎樣用vb編寫乙個檔案加密程式

6樓:匿名使用者

全過程是什麼說。是不是完整原始碼啊。我這台機沒裝vb。只能聲援一下。給個思路。 異或吧。異或個二次。應該夠你用了

7樓:匿名使用者

dim i as byte

open "c:\copy of rhdsetup.log" for binary as #1

open "c:\copy of rhdsetup.log" & "~~" for binary as #2

do while not eof(1)

get #1, , i

i = i xor 8

put #2, , i

loop

close #1

close #2

kill "c:\copy of rhdsetup.log"

name "c:\copy of rhdsetup.log" & "~~" as "c:\copy of rhdsetup.log"

vb 加密與解密的程式** 5

8樓:大野瘦子

加密:private function jiami(byval varpass as string) as string '引數varpass是需要加密的文字內容

dim varjiami as string * 20

dim vartmp as double

dim strjiami as string

dim i

for i = 1 to len(varpass)

vartmp = ascw(mid$(varpass, i, 1))

varjiami = str$(((((vartmp * 1.5) / 5.6) * 2.7) * i))

strjiami = strjiami & varjiami

next i

jiami = strjiami

end function

解密函式:

private function jiemi(byval varpass as string) as string '引數varpass是需要解密的密文內容

dim varreturn as string * 20

dim varconvert as double

dim varfinalpass as string

dim varkey as integer

dim varpasslenth as long

varpasslenth = len(varpass)

for i = 1 to varpasslenth / 20

varreturn = mid(varpass, (i - 1) * 20 + 1, 20)

varconvert = val(trim(varreturn))

varconvert = ((((varconvert / 1.5) * 5.6) / 2.7) / i)

varfinalpass = varfinalpass & chrw(val(varconvert))

next i

jiemi = varfinalpass

end function

9樓:匿名使用者

我給你兩個加解密的函式吧,乙個是加密、乙個是解密,兩個是對應的。你只要將這兩個函式複製到需要加密和解密的窗體**內即可呼叫了。源**如下:

'加密函式

private function jiami(byval varpass as string) as string '引數varpass是需要加密的文字內容

dim varjiami as string * 20

dim vartmp as double

dim strjiami as string

dim i

for i = 1 to len(varpass)

vartmp = ascw(mid$(varpass, i, 1))

varjiami = str$(((((vartmp * 1.5) / 5.6) * 2.7) * i))

strjiami = strjiami & varjiami

next i

jiami = strjiami

end function

'解密函式

private function jiemi(byval varpass as string) as string '引數varpass是需要解密的密文內容

dim varreturn as string * 20

dim varconvert as double

dim varfinalpass as string

dim varkey as integer

dim varpasslenth as long

varpasslenth = len(varpass)

for i = 1 to varpasslenth / 20

varreturn = mid(varpass, (i - 1) * 20 + 1, 20)

varconvert = val(trim(varreturn))

varconvert = ((((varconvert / 1.5) * 5.6) / 2.7) / i)

varfinalpass = varfinalpass & chrw(val(varconvert))

next i

jiemi = varfinalpass

end function

10樓:寂寞遊神

額....這個沒用過行

VB程式設計遇到的乙個問題,關於VB程式設計的小問題

二樓的是錯誤的,寫成 會出錯,直接寫成 就行了。至於怎樣用user變數作為過度變數,關鍵是要將user定義為函式形式而不是變數形式,具體做法如下 a.公共部分 option explicit public function user s as string as string user s end ...

有關VB程式設計的問題,什麼是VB程式設計

用7個文字框 設定為控制項陣列,即連續複製乙個文字框,跳出提示框點是 輸入7個成績。private sub command1 click dim a 7 as single,i as integer,max as single,min as single,s as single,sum as sin...

用高階程式語言編寫的程式

用高階程式語言編寫的程式可讀性好,但不能被機器直接執行。高階程式語言的可閱讀性更強,能夠方便的表達程式的功能,但高階程式語言因為是一種編譯語言,所以它的執行速度比匯程式設計序要低,同時因為高階語言比較冗長,所以 的執行速度也要慢一些。另外,高階程式語言的架構高於彙編,不能編寫直接訪問硬體資源的系統程...