⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 一个加密解密程序
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1 
   BackColor       =   &H8000000D&
   Caption         =   "加密解密应用程序--JDWH"
   ClientHeight    =   5430
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   8475
   LinkTopic       =   "Form1"
   ScaleHeight     =   5430
   ScaleWidth      =   8475
   StartUpPosition =   3  '窗口缺省
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   240
      Top             =   4560
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.TextBox txtNote 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   3015
      Left            =   240
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   4
      Top             =   1080
      Width           =   5895
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "退出"
      Height          =   495
      Left            =   6600
      TabIndex        =   3
      Top             =   3600
      Width           =   1335
   End
   Begin VB.CommandButton cmdDecrypt 
      Caption         =   "解密"
      Height          =   495
      Left            =   6600
      TabIndex        =   2
      Top             =   2640
      Width           =   1335
   End
   Begin VB.CommandButton cmdEncrypt 
      Caption         =   "加密"
      Height          =   495
      Left            =   6600
      TabIndex        =   1
      Top             =   1680
      Width           =   1335
   End
   Begin VB.Label lblFile 
      BackColor       =   &H8000000D&
      Caption         =   "输入文本并保存到硬盘"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   240
      TabIndex        =   0
      Top             =   360
      Width           =   5895
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub cmdDecrypt_Click()
    Wrap$ = Chr$(13) + Chr$(10) 'create wrap character
    CommonDialog1.Filter = "Text files (*.TXT)|*.TXT"
    CommonDialog1.ShowOpen      'display Open dialog box
    If CommonDialog1.FileName <> "" Then
        Form1.MousePointer = 11 'display hourglass
        Open CommonDialog1.FileName For Input As #1 'open file
        On Error GoTo Problem:  'set error handler
        Do Until EOF(1)         'copy each line of text to
            Line Input #1, LineOfText$  'AllText$ string
            AllText$ = AllText$ & LineOfText$ & Wrap$
        Loop
        'now, decrypt string by subtracting one from ASCII code
        decrypt$ = ""   'initialize string for decryption
        charsInFile = Len(AllText$)  'get length of string
        For i% = 1 To charsInFile    'loop once for each char
            letter$ = Mid(AllText$, i%, 1)  'get char with Mid
            decrypt$ = decrypt$ & Chr$(Asc(letter) - 1) 'subtract 1
        Next i%                       'and build new string
        txtNote.Text = decrypt$ 'then display converted string
        lblFile.Caption = CommonDialog1.FileName 'set caption
CleanUp:                        'when finished...
        Form1.MousePointer = 0  'reset mouse
        Close #1                'close file
        CommonDialog1.FileName = ""   'clear filename
    End If
    Exit Sub
Problem:  'if there is a problem, display appropriate message
    MsgBox "Error Opening File", , Err.Description
    lblFile.Caption = ""        'remove caption
    txtNote.Text = ""           'clear text box
    Resume CleanUp:   'finally, finish with CleanUp routine
End Sub

Private Sub cmdEncrypt_Click()
    CommonDialog1.Filter = "Text files (*.TXT)|*.TXT"
    CommonDialog1.ShowSave           'display Save dialog
    If CommonDialog1.FileName <> "" Then
        Form1.MousePointer = 11      'display hourglass
        lblFile.Caption = CommonDialog1.FileName
        'save text with encryption scheme (ASCII code + 1)
        encrypt$ = ""  'initialize encryption string
        charsInFile% = Len(txtNote.Text) 'find string length
        For i% = 1 To charsInFile%   'for each character in file
            letter$ = Mid(txtNote.Text, i%, 1) 'read next char
            'determine ASCII code of char and add one to it
            encrypt$ = encrypt$ & Chr$(Asc(letter$) + 1)
        Next i%
        Open CommonDialog1.FileName For Output As #1 'open file
        Print #1, encrypt$           'save encrypted text to file
        txtNote.Text = encrypt$
        Close #1                     'close file
        CommonDialog1.FileName = ""  'clear filename
        Form1.MousePointer = 0       'reset mouse
    End If
End Sub

Private Sub cmdExit_Click()
    End
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -