The simplest encryption and decryption algorithm

Source: Internet
Author: User
Tags decrypt

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.ComponentModel;4 usingSystem.Data;5 usingSystem.Drawing;6 usingSystem.Linq;7 usingSystem.Text;8 usingSystem.Windows.Forms;9 Ten namespaceWindowsFormsApplication1 One { A      Public Partial classForm1:form -     { -          PublicForm1 () the         { - InitializeComponent (); -         } -  +         Private voidForm1_Load (Objectsender, EventArgs e) -         { +              A         } at  -         Private voidButton1_Click (Objectsender, EventArgs e) -         { -             //Encrypt -             strings = This. TextBox1.Text; -             stringss=Encrypt (s); in              This. TextBox2.Text =SS; -  to         } +         Private voidButton2_Click (Objectsender, EventArgs e) -         { the             //decryption *             strings = This. TextBox1.Text; $             stringSS =Decryptor (s);Panax Notoginseng              This. TextBox2.Text =SS; -              the         } +         #regionEncryption A          Public stringEncrypt (strings) the         { +Encoding ASCII = ENCODING.ASCII;//instantiated.  -             stringEncryptString ="";//defined.  $              for(inti =0; i < s.length; i++)//traversal.  $             { -                 intJ; -                 byte[] B =New byte[1]; thej = Convert.ToInt32 (ASCII. GetBytes (S[i]. ToString ()) [0]);//gets the ASCII of the character.  -j = j +5;//EncryptWuyib[0] = Convert.tobyte (j);//converts to a eight-bit unsigned integer.  theencryptstring = encryptstring + ASCII. GetString (b);//display.  -  Wu             } -             returnencryptstring; About         }  $         #endregion -         //decryption -         #regionDecrypt -          Public stringDecryptor (strings) A         { +Encoding ASCII = ENCODING.ASCII;//instantiated.  the             stringDecryptorstring ="";//defined.  -              for(inti =0; i < s.length; i++)//traversal.  $             { the                 intJ; the                 byte[] B =New byte[1]; thej = Convert.ToInt32 (ASCII. GetBytes (S[i]. ToString ()) [0]);//gets the ASCII of the character.  thej = J-5;//decryption -b[0] = Convert.tobyte (j);//converts to a eight-bit unsigned integer.  indecryptorstring = decryptorstring + ASCII. GetString (b);//display.  the  the             } About             returndecryptorstring; the         }  the         #endregion the  +         -     } the}

Encryption:

Decrypt:

The simplest encryption and decryption algorithm

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.