Create an application, then change the size of the form, and place 2 COMANDBUTTON, 3 Label, and 3 TextBox components on the form. Change the form, three Label components, and two CAPTION attributes of the two COMANDBUTTONs to: "Simple Encrypted Program", "Encrypted Password", "Original", "Cipheet", "Encryption", "Decrypt".
The specific code is as follows:
PRIVATE FUNCTION NUMERICPASSWORD (BYVAL Password AS STRING) AS Longdim Value As Longdim Chift2 AS Longdim I as Integerdim Str_len As Integer
STR_LEN = LEN (Password) for i = 1 to str_len ch = ASC (MID $ (Password, I, 1)) 'After shifting the value of Shift1 and Value Direct or Value = Value XOR (CH * 2 ^ shift1)' After shift2 bit and VALUE is different or value value = value xor (chift1 7) mod 19 shift2 = (shift2 13) mod 19 shift2 = (shift2 13) mod 19 shift2 = (shift2 13) MOD 23 Next i numericpassword = Value
END FUNCTION
Private Sub cmdCipher_Click () Dim cipher_text As StringConst MIN_ASC = 32 'spaces Const MAX_ASC = 126' ~ .Const NUM_ASC = MAX_ASC - MIN_ASC 1Dim offset As LongDim str_len As IntegerDim i As IntegerDim ch As Integer 'initialize the random code generator offset = NumericPassword (txtpassword.text) rnd -1 randomize offset 'encrypted string str_len = len (txtplain.text) for i = 1 to str_len ch = ASC (MID $ (txtplain.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 Cipher_text = Cipher_Text & Chr $ (CH) end if next i txtcipher.text = cipher_text end sub
Private Sub cmdDecipher_Click () Dim plain_text As StringConst MIN_ASC = 32 'spaces Const MAX_ASC = 126' ~ .Const NUM_ASC = MAX_ASC - MIN_ASC 1Dim offset As LongDim str_len As IntegerDim i As IntegerDim ch As Integer 'initialize the random code generator offset = NumericPassword (txtpassword.text) rnd -1 randomize offset 'decryption string str_len = len (txtcipher.text) for i = 1 to str_len ch = ASC (MID $ (txtcipher.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 PLAIN_TEXT = Plain_Text & Chr $ (CH) end if next i txtplain.text = plain_textend sub
Private Sub txtPassword_Change () If Len (txtPassword.Text)> 0 Then cmdCipher.Enabled = True cmdDecipher.Enabled = True Else cmdCipher.Enabled = False cmdDecipher.Enabled = False End If End Sub
----------------------------
Welcome all the colleagues, communicate with each other, and make progress!
----------------------------