I am trying to pick up cryptography and had been trying this exercise
Write a program (preferably Java) to generate a one-time pad, which is a relatively large file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace one_time_pad
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(" TRYING\n");
Console.WriteLine("Enter : ");
int input= int.Parse( Console.ReadLine());
//random num generation
Random rnd = new Random();
int random = rnd.Next(1,10);
//binary conversion
string binary = Convert.ToString(random,2);
string inbinary = Convert.ToString(input,2);
Console.WriteLine("Data : " +input +" Binary : " + inbinary);
Console.WriteLine(" Key : " +random + " Binary : " + binary);
// taking xor
int Ghul = input ^ random;
//binary conversion
string intcon = Convert.ToString(Ghul,2);
Console.WriteLine("Encrypted : " + intcon);
Console.WriteLine(":)");
Console.Read();
}
}
}