📄 decryption.cs
字号:
using System;
namespace Encrypt
{
/// <summary>
/// Summary description for Decryption.
/// </summary>
public class Decryption
{
public Decryption()//constructor
{
}
//this method takes in two string as arguments(the message to decrypt
//and the key value inputted by the user and returns a string
public string Decrypt(string msgtodecrypt, 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< msgtodecrypt.Length; i++)
{
//first bit in string converted to 32bit inter and set as num
numint = Convert.ToInt32( msgtodecrypt[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 + -