Encryption | decryption | algorithm /************************* string Encryption Algorithm ***********************/
public string encryptstring (String str)
{
char[] base64code=new char[]{' A ', ' B ', ' C ', ' d ', ' e ', ' f ', ' g ', ' h ', ' I ', ' j ', ' K ', ' l ', ' m ', ' n ', ' o ', ' P ', ' Q ', ' R ', ' s ', ' t ', ' u ' , ' V ', ' w ', ' x ', ' y ', ' z ', ' A ', ' B ', ' C ', ' D ', ' E ', ' F ', ' G ', ' H ', ' I ', ' J ', ' K ', ' L ', ' M ', ' N ', ' O ', ' P ', ' Q ', ' R ', ' S ', ' T ', ' U ', ' V ', ' W ', ' X ', ' Y ', ' Z ', ' 0 ', ' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 5 ', ' 6 ', ' 7 ', ' 8 ', ' 9 ', ' + ', '/', ' = '};
byte empty= (byte) 0;
System.Collections.ArrayList bytemessage=new System.Collections.ArrayList (System.Text.Encoding.Default.GetBytes ( STR));
System.Text.StringBuilder Outmessage;
int messagelen=bytemessage.count;
int PAGE=MESSAGELEN/3;
int use=0;
if ((use=messagelen%3) >0)
{
for (int i=0;i<3-use;i++)
Bytemessage.add (empty);
page++;
}
Outmessage=new System.Text.StringBuilder (page*4);
for (int i=0;i<page;i++)
{
byte[] InStr = new Byte[3];
Instr[0]= (Byte) bytemessage[i*3];
Instr[1]= (Byte) bytemessage[i*3+1];
Instr[2]= (Byte) bytemessage[i*3+2];
Int[] Outstr=new int[4];
outstr[0]=instr[0]>>2;
When encrypting a file, it reads the contents of the file into a string variable, encrypts the string, and finally writes the encrypted string to the file. See:
File operation. txt.
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.