Plaintext Encryption, plaintext

Source: Internet
Author: User

Plaintext Encryption, plaintext

How can we better encrypt a string? MD5, RSA, DES?

Okay, you don't understand this.

After referring to du Niang, the idea is:

For encryption:

· Extract a character from the string to be encrypted

· Take the lower byte of the character and Key1 for exclusive or operation

· Take the high byte of the character

· Synthesize the computed data into new characters

For decryption:

· Extract a character from the string to be decrypted

· Take the lower byte of the character and Key1 for exclusive or operation

· Take the high byte of the character

· Synthesize the computed data into new characters

With this method, you can complete the following functions:

This encryption method can only be used in English and Chinese, but cannot be decrypted...

Encryption (Encryption ):

Private Function Encrypt (ByVal StrSource As String) as String 'encrypt Dim BLowData As your BHigData As your SHigData As your I As LongDim k As IntegerDim StrEncrypt As StringDim StrChar As StringDim KeyTemp As StringDim Key1 As Byte For k = 1 To 30 KeyTemp = keyTemp & CStr (Int (Rnd * (9) + 1) Next Key1 = CByte (Mid (KeyTemp, 11, 1) & Mid (KeyTemp, 27, 1) For I = 1 To Len (StrSource) strChar = Mid (StrSource, I, 1) 'extract one character from the string to be encrypted BLowData = AscB (MidB (StrChar, 1, 1 )) xor key1' lower byte and Key1 for the Xor operation SHigData = AscB (MidB (StrChar, 2, 1) 'to take the character's high byte StrEncrypt = StrEncrypt & ChrB (BLowData) & ChrB (BHigData) 'combines the computed data into the new character Next I Encrypt = KeyTemp & StrEncryptEnd Function

Decryption (Decryption ):

Private Function Decrypt (ByVal StrSource As String) as String 'decrypt Dim BLowData As ByteDim BHigData As I As LongDim k As IntegerDim StrDecrypt As StringDim StrChar As StringDim KeyTemp As StringDim Key1 As ByteKeyTemp = Mid (StrSource, 1, 30) key1 = CByte (Mid (KeyTemp, 11, 1) & Mid (KeyTemp, 27, 1) For I = 31 To Len (StrSource) StrChar = Mid (StrSource, I, 1) 'extract one character from the string to be decrypted BLowData = AscB (MidB (StrChar, 1, 1 )) xor key1' calculate the low byte of the character and Key1 for the Xor operation BHigData = AscB (MidB (StrChar, 2, 1) 'to obtain the high byte StrDecrypt = StrDecrypt & ChrB (BLowData) & ChrB (BHigData) 'combines the computed data into the new character Next iDecrypt = StrDecryptEnd Function


In addition, considering the complexity of encryption characters, create a command to copy to the clipboard:

Private Sub copyl_Click()Clipboard.ClearClipboard.SetText (jiemit.Text)End Sub


Therefore:

Option Explicit 'copyright (c) 2014, School of Computer Science, Yantai University 'all right reserved. 'author: Shao Shuai 'file: Project 1. vsp completion time: July 22, February 26, 2015 version: v1.0.1Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _ ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPrivate Declare Function ReleaseCapture Lib "user32 "() as LongPrivate Const WM_SYSCOMMAND = & hsf-private Const SC _MOVE = & HF010 & Private Const HTCAPTIO = 2 Private Function Encrypt (ByVal StrSource As String) as String 'encrypt Dim BLowData As your BHigData As your SHigData As your I As LongDim k As IntegerDim StrEncrypt As StringDim StrChar As StringDim KeyTemp As StringDim Key1 As Byte For k = 1 To 30 KeyTemp = keyTemp & CStr (Int (Rnd * (9) + 1) Next Key1 = CByte (Mid (KeyTemp, 11, 1) & Mid (KeyTemp, 27, 1) For I = 1 To Len (StrSource) strChar = Mid (StrSource, I, 1) 'extract one character from the string to be encrypted BLowData = AscB (MidB (StrChar, 1, 1 )) xor key1' lower byte and Key1 for the Xor operation SHigData = AscB (MidB (StrChar, 2, 1) 'to take the character's high byte StrEncrypt = StrEncrypt & ChrB (BLowData) & ChrB (BHigData) 'combines the computed data into the new character Next I Encrypt = KeyTemp & StrEncryptEnd FunctionPrivate Function Decrypt (ByVal StrSource As String) as String 'decrypt Dim BLowData As ByteDim BHigData As I As LongDim k As IntegerDim StrDecrypt As StringDim StrChar As StringDim KeyTemp As StringDim Key1 As ByteKeyTemp = Mid (StrSource, 1, 30) key1 = CByte (Mid (KeyTemp, 11, 1) & Mid (KeyTemp, 27, 1) For I = 31 To Len (StrSource) StrChar = Mid (StrSource, I, 1) 'extract one character from the string to be decrypted BLowData = AscB (MidB (StrChar, 1, 1 )) xor key1' calculate the low byte of the character and Key1 for the Xor operation BHigData = AscB (MidB (StrChar, 2, 1) 'to obtain the high byte StrDecrypt = StrDecrypt & ChrB (BLowData) & ChrB (BHigData) 'combines the computed data into the new character Next iDecrypt = StrDecryptEnd FunctionPrivate Sub clearl_Click () jiamit. text = "" jiemit. text = "" End SubPrivate Sub close_Click () EndEnd SubPrivate Sub copyl_Click () Clipboard. clearClipboard. setText (jiemit. text) End SubPrivate Sub Image1_Click () End SubPrivate Sub jiamil_Click () jiemit. text = Encrypt (jiamit. text) End SubPrivate Sub jiemil_Click () jiemit. text = Decrypt (jiemit. text) End SubPrivate Sub labFormTitle_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single) ReleaseCapture 'wm _ SYS sends a mobile form command Call SendMessage (Me. hwnd, WM_SYSCOMMAND, SC _MOVE + HTCAPTIO, 0) 'SC _ MOVE + HTCAPTIO indicates that the left-click MOVE form End SubPrivate Sub mini_Click () If Me. windowState = 0 Then Me. windowState = 1End IfEnd Sub

Okay. By the way, I wrote a UI, which is a pure English interface. I can also learn English on the tall floor. Because I wrote this code, I knew how to write encryption and decryption in English.

,


Full of characters, instantly cannot guess.

Download:

Plaintext Encryption


@ Mayuko




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.