decryption.cs

来自「This code is a cipher which takes in a p」· CS 代码 · 共 50 行

CS
50
字号
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 + =
减小字号Ctrl + -
显示快捷键?