alexdmin

taskfasjfh

Sep 11th, 2021
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.55 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using ConsoleTables;
  6. using System.Security.Cryptography;
  7. using System.Threading.Tasks;
  8.  
  9.  
  10. namespace task3
  11. {
  12.     class Program
  13.     {
  14.         static void Main(string[] args)
  15.         {
  16.             /* int BotChoice = keygen.BotChoice();
  17.              Console.WriteLine(BotChoice);
  18.  
  19.              string BotKey = keygen.getkey(BotChoice);
  20.              Console.WriteLine(BotKey);
  21.  
  22.              byte[] bytes = Encoding.ASCII.GetBytes(BotKey);
  23.              string HMAC = keygen.getHMAC(bytes);
  24.              Console.WriteLine(HMAC);
  25.              Console.ReadKey();  
  26.             */
  27.             string a = result.getResult(2,1);
  28.             Console.WriteLine(a);
  29.            
  30.  
  31.             table.getTable();
  32.  
  33.             Console.ReadKey();
  34.  
  35.         }
  36.     }
  37.     public class keygen
  38.     {
  39.         public static int BotChoice()
  40.         {        
  41.             Random random = new System.Random();
  42.             int KeyValue = random.Next(1, 5);
  43.             return KeyValue;
  44.         }
  45.         public static string getkey(int BotValue)
  46.         {
  47.              System.Security.Cryptography.AesCryptoServiceProvider crypto = new System.Security.Cryptography.AesCryptoServiceProvider();
  48.              crypto.KeySize = 128;
  49.              crypto.BlockSize = 128;
  50.              crypto.GenerateKey();
  51.              byte[] keyGenerated = crypto.Key;
  52.              string Key = Convert.ToBase64String(keyGenerated);
  53.              return Key;
  54.            
  55.         }
  56.         public static string getHMAC(byte[] a)
  57.         {
  58.             var HMACValue = new HMACSHA256(a);
  59.             var HMACKey = Convert.ToBase64String(HMACValue.Key);
  60.             return HMACKey;
  61.  
  62.         }
  63.        
  64.     }
  65.     public class result
  66.     {
  67.         public static string getResult(int PlayerChoice, int BotChoice)
  68.         {
  69.             int test = (5 + PlayerChoice - BotChoice) % 5;
  70.             string result;
  71.             if (test == 2 || test == 4) result = "YOU WIN";
  72.             else if (test == 1 || test == 3) result = "YOU LOSE";
  73.             else result = "TIE";
  74.             return result;
  75.         }
  76.     }
  77.     public class table
  78.     {
  79.         public static void getTable()
  80.         {
  81.             var table = new ConsoleTable("one", "two", "three");
  82.             table.AddRow(1, 2, 3)
  83.                      .AddRow("this line should be longer", "yes it is", "oh");
  84.  
  85.             table.Write(Format.Alternative);
  86.             Console.WriteLine();
  87.             Console.ReadKey();
  88.         }
  89.     }
  90. }
  91.  
Add Comment
Please, Sign In to add comment