Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- string secretword = Console.ReadLine();
- string message = Console.ReadLine();
- int sum = 0;
- int r;
- foreach( char c in secretword)
- {
- sum += (int)c;
- }
- int mask = 0;
- while (sum != 0)
- {
- r = sum % 10;
- sum = sum / 10;
- mask = mask + r;
- }
- //char[] newArr = message.ToCharArray();
- string encryption = string.Empty;
- for(int i=0;i<message.Length;i++)
- {
- char currChar = message[i];
- if(currChar%mask==0)
- {
- currChar +=(char)(mask);
- }
- else
- {
- currChar -= (char)(mask);
- }
- encryption += currChar;
- }
- char[] eArray = encryption.ToCharArray();
- Array.Reverse(eArray);
- Console.WriteLine(eArray);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement