📄 encryption.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Encrypt
{
/// <summary>
/// Summary description for Encryption.
/// </summary>
public class Encryption
{
public Encryption()
{
}
//this method takes in two string as arguments(the message to encrypt
//and the key value inputted by the user and returns a string
public string Encrypt(string msgtoencrypt, string inc)
{
string temp= "";//initiate string
char charnum; //initiate chars
char charresult;
int tempint = 0; //initiate ints
int numint = 0;
int valint = 0;
//set val equal to inc passed into fuction.inc is converted to a
//32 bit integer
valint = Convert.ToInt32(inc);
//for loop,loops while i is less than the message length
for(int i=0; i< msgtoencrypt.Length; i++)
{
//first bit in string converted to 32bit inter and set as numint
numint = Convert.ToInt32( msgtoencrypt[i]);
//this then converted to a char and set as numint
charnum = Convert.ToChar(numint);
//tempint then set to charnum + valint
tempint = charnum + valint;
//this then converted to a char and set as charresult
charresult = Convert.ToChar(tempint);
//this then converted to a string so it can be passed back
temp = temp + charresult.ToString();
}
return temp;//returns the temp value
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -