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 ConsoleTables;
- using System.Security.Cryptography;
- using System.Threading.Tasks;
- namespace task3
- {
- class Program
- {
- static void Main(string[] args)
- {
- /* int BotChoice = keygen.BotChoice();
- Console.WriteLine(BotChoice);
- string BotKey = keygen.getkey(BotChoice);
- Console.WriteLine(BotKey);
- byte[] bytes = Encoding.ASCII.GetBytes(BotKey);
- string HMAC = keygen.getHMAC(bytes);
- Console.WriteLine(HMAC);
- Console.ReadKey();
- */
- string a = result.getResult(2,1);
- Console.WriteLine(a);
- table.getTable();
- Console.ReadKey();
- }
- }
- public class keygen
- {
- public static int BotChoice()
- {
- Random random = new System.Random();
- int KeyValue = random.Next(1, 5);
- return KeyValue;
- }
- public static string getkey(int BotValue)
- {
- System.Security.Cryptography.AesCryptoServiceProvider crypto = new System.Security.Cryptography.AesCryptoServiceProvider();
- crypto.KeySize = 128;
- crypto.BlockSize = 128;
- crypto.GenerateKey();
- byte[] keyGenerated = crypto.Key;
- string Key = Convert.ToBase64String(keyGenerated);
- return Key;
- }
- public static string getHMAC(byte[] a)
- {
- var HMACValue = new HMACSHA256(a);
- var HMACKey = Convert.ToBase64String(HMACValue.Key);
- return HMACKey;
- }
- }
- public class result
- {
- public static string getResult(int PlayerChoice, int BotChoice)
- {
- int test = (5 + PlayerChoice - BotChoice) % 5;
- string result;
- if (test == 2 || test == 4) result = "YOU WIN";
- else if (test == 1 || test == 3) result = "YOU LOSE";
- else result = "TIE";
- return result;
- }
- }
- public class table
- {
- public static void getTable()
- {
- var table = new ConsoleTable("one", "two", "three");
- table.AddRow(1, 2, 3)
- .AddRow("this line should be longer", "yes it is", "oh");
- table.Write(Format.Alternative);
- Console.WriteLine();
- Console.ReadKey();
- }
- }
- }
Add Comment
Please, Sign In to add comment