コード例 #1
0
ファイル: Program.cs プロジェクト: Carpunder/RockPaper
        static void Main(string[] args)
        {
            if (!UniqueElems(args) || args.Length < 3)
            {
                throw new Exception("Error");
            }
            RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();

            byte[] buff = new byte[16];
            RandomNumberGenerator.Create().GetBytes(buff);
            var hmacsha256 = new HMACSHA256(buff);
            var computer   = args[RandomNumberGenerator.GetInt32(0, args.Length - 1)];
            var hash       = Convert.ToHexString(hmacsha256.ComputeHash(ASCII.GetBytes(computer)));

            Console.WriteLine("HMAC:" + hash);

            Console.WriteLine("Available Moves: ");
            for (int i = 0; i < args.Length; i++)
            {
                Console.WriteLine($"{i+1} - {args[i]}");
            }
            Console.Write($"{0} - Exit \nEnter your move: ");
            int user = int.Parse(Console.ReadLine());

            Console.WriteLine($"Your move: {args[user-1]}\nComputer move: {computer}");

            if (computer == args[user - 1])
            {
                Console.WriteLine("Draw");
            }

            if (!Winners(args, user).Contains(computer))
            {
                Console.WriteLine("You Win!");
            }
            else
            {
                Console.WriteLine("You Lose!");
            }
            Console.WriteLine($"HMAC Key: {Convert.ToHexString(buff)}");
        }
コード例 #2
0
ファイル: Perf.Convert.cs プロジェクト: dotnet/performance
 public string ToHexString() => Convert.ToHexString(_binaryData);