PlainText encryption-plaintext encryption P.E.

Source: Internet
Author: User

How to better encrypt a string? MD5, RSA, DES?

Well, none of this is understood.

Reference to the degree Niang, so the idea is:

For encryption:

· Remove a character from the string to be encrypted

· The low-byte and Key1 of the characters are taken to make an XOR operation

· Take the high byte of the character

· Synthesize the data after the operation to a new character

For decryption:

· Remove a character from the string to decrypt

· The low-byte and Key1 of the characters are taken to make an XOR operation

· Take the high byte of the character

· Synthesize the data after the operation to a new character

With the method, you can complete the following function:

This encryption method is only used in English, Chinese can also be encrypted, but cannot decrypt ...

Encryption (encryption):

Private Function Encrypt (ByVal strsource As String) As String    ' encrypt Dim blowdata As Bytedim bhigdata as Bytedim shigdata As Bytedim I as Longdim K as Integerdim Strencrypt as StringDim Strchar as StringDim keytemp as StringDim Key1 as Byte
   
    for k = 1 to    keytemp = keytemp & CStr (Int (RND * (9) + 1))    Next    Key1 = CByte (Mid (Keytemp, one, 1) &  Mid (Keytemp, 1)) for    i = 1 to Len (strsource)    Strchar = Mid (strsource, I, 1)  ' Remove a character from the string to be encrypted    Blowdata = AscB (MidB (Strchar, 1, 1)) Xor Key1    ' take characters of low byte and Key1 for XOR operation    shigdata = AscB (MidB (Strchar, 2, 1))   ' Take the high byte of the character    strencrypt = strencrypt & ChrB (blowdata) & ChrB (bhigdata)    ' synthesizes the data after the operation of the new character    Next i    Encrypt = Keytemp & Strencryptend Function
   

Decryption (decryption):

Private Function Decrypt (ByVal strsource As String) As String     ' decryption Dim blowdata As Bytedim Bhigdata as Bytedim i as Long  Dim K as Integerdim Strdecrypt as StringDim Strchar as StringDim keytemp as StringDim Key1 as Bytekeytemp = Mid (strsource, 1) Key1 = CByte (Mid (Keytemp, one, 1) & Mid (Keytemp, 1)) For i =---Len (strsource) Strchar = Mid (strsource, I, 1)    ' Remove a character from the string to be decrypted blowdata = AscB (MidB (Strchar, 1, 1)) XOR Key1   ' Take the low byte of the character and Key1 for XOR operation Bhigdata = AscB (MidB ( Strchar, 2, 1)      ' Take the character of the high byte Strdecrypt = strdecrypt & ChrB (blowdata) & ChrB (bhigdata)   ' to synthesize the calculated data after the new character next Idecrypt = Strdecryptend Function


also, given the complexity of the cryptographic characters, create a command to copy to the Clipboard:

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


So:

Option Explicit ' Copyright (c) 2014, Yantai University School of Computer ' all right reserved. ' Shao ' file: Project 1.vsp ' finish: February 26, 2015 ' Version number: V1.0.1private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd as Long, _byval wmsg as Long, ByVal WParam as L Ong, LParam as any) as Longprivate Declare Function releasecapture Lib "user32" () as longprivate Const Wm_syscommand = &A mp h112private Const SC_MOVE = &hf010&private Const Htcaptio = 2Private Function Encrypt (ByVal strsource as String) A S String ' encrypt Dim blowdata As Bytedim Bhigdata as Bytedim shigdata as Bytedim i as Longdim K as Integerdim Strencrypt as StringDim Strchar as StringDim keytemp as StringDim Key1 as Byte for k = 1 to Keytemp = keytemp & CStr (Int (Rn D * (9) + 1)) Next Key1 = CByte (Mid (Keytemp, one, 1) & Mid (Keytemp, strsource, 1)) For i = 1 to Len () Str Char = Mid (strsource, I, 1) ' Remove a character from the string to be encrypted Blowdata = AscB (MidB (Strchar, 1, 1)) XOR Key1 ' Take the low byte of the character and Key1 for XOR operation SH Igdata = AscB (MidB (Strchar, 2, 1)) ' High byte Strencrypt = strencrypt & ChrB (blowdata) & ChrB (Bhigdata) ' to synthesize new characters from the calculated data next i Encryp t = keytemp & strencryptend functionprivate Function Decrypt (ByVal strsource As String) As String decrypt Dim blowdata As Bytedim Bhigdata as Bytedim i as Longdim K as Integerdim Strdecrypt as StringDim Strchar as StringDim keytemp as String Dim Key1 as Bytekeytemp = Mid (strsource, 1,) Key1 = CByte (Mid (Keytemp, 1) & Mid (Keytemp, 1)) for i = from to Le N (strsource) Strchar = Mid (strsource, I, 1) ' Remove a character from the string to be decrypted blowdata = AscB (MidB (Strchar, 1, 1)) Xor Key1 ' Take the low byte of the character and Key1   Make an XOR operation Bhigdata = AscB (MidB (Strchar, 2, 1)) ' Take character high byte Strdecrypt = strdecrypt & ChrB (blowdata) & ChrB (Bhigdata) ' Synthesize the data after 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) Releaseca Pture ' Wm_sys send a mobile form command to a form call SendMessage (Me.hwnd, Wm_syscommand, Sc_move + htcaptio, 0) ' sc_move+ htcaptio means left-click to move Form E nd SubPrivate Sub Mini_click () If me.windowstate = 0 Then me.windowstate = 1End IfEnd Sub

Well, by the way write a UI, plain English interface, tall Wood has, can also learn English, because wrote this code, I know the encryption and decryption of the English wording.



Full of characters, instantly guessed not to have the wood there.

Download:

PlainText encryption


@ Mayuko




PlainText encryption-plaintext encryption P.E.

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.