private static void Main() { var hexConverter = new HexadecimalConverter(new DecimalNumber("101010101111.1010")); var hexNumber = hexConverter.Convert(); Console.WriteLine(hexNumber); // 0x1784ABD377.19DB22 }
/// <summary> /// To string /// </summary> /// <param name="originalStr"></param> /// <param name="fromStyle"></param> /// <param name="encoding"></param> /// <returns></returns> public static string CastToString(this string originalStr, ScaleStyles fromStyle = ScaleStyles.String, Encoding encoding = null) { return(fromStyle switch { ScaleStyles.Hexadecimal => HexadecimalConverter.ToString(originalStr, encoding), _ => originalStr });
public void ToHexadecimal_WhenNumberEquals205_ReturnsCD() { var convert = new HexadecimalConverter(); string result = convert.ToHexadecimal(205); Assert.AreEqual("CD", result); }
public void ToHexadecimal_WhenNumberEquals1_Returns1() { var convert = new HexadecimalConverter(); string result = convert.ToHexadecimal(1); Assert.AreEqual("1", result); }
public void Hexadecimal_Converter_Test() { IConverter hexConverter = new HexadecimalConverter(new BinaryNumber("101010101111.1010")); var converted = hexConverter.Convert(); converted.IntegerPart.Should().Be("AAF"); converted.FloatPart.Should().Be("A00000"); converted.Base.Should().Be(16); converted.ToString().Should().Be("0xAAF.A00000"); hexConverter = new HexadecimalConverter(new DecimalNumber("101010101111.1010")); converted = hexConverter.Convert(); converted.IntegerPart.Should().Be("1784ABD377"); converted.FloatPart.Should().Be("19DB22"); converted.Base.Should().Be(16); converted.ToString().Should().Be("0x1784ABD377.19DB22"); hexConverter = new HexadecimalConverter(new OctalNumber("101010101111.1010")); converted = hexConverter.Convert(); converted.IntegerPart.Should().Be("208208249"); converted.FloatPart.Should().Be("207FFD"); converted.Base.Should().Be(16); converted.ToString().Should().Be("0x208208249.207FFD"); hexConverter = new HexadecimalConverter(new HexadecimalNumber("101010101111.1010")); converted = hexConverter.Convert(); converted.IntegerPart.Should().Be("101010101111"); converted.FloatPart.Should().Be("1010"); converted.Base.Should().Be(16); converted.ToString().Should().Be("0x101010101111.1010"); }
static void Main(string[] args) { HexadecimalConverter Hexadecimal = new HexadecimalConverter(); Console.WriteLine("Enter String:"); string name = Console.ReadLine(); string hexval = Hexadecimal.ConvertTo(name); Console.WriteLine("Hex value of " + name + " = " + hexval); Encoding encode = System.Text.Encoding.UTF8; string hexString = hexval; var intlen = (int)(hexString.Length / 2); var bytes = new byte[hexString.Length / 2]; for (var i = 0; i < intlen; i++) { bytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16); } //command to decode the corresponding UTF8 code of binary value string ConvertedStr = encode.GetString(bytes); Console.WriteLine("Hex To String = " + ConvertedStr); Console.WriteLine("\n"); }
/// <summary> /// To decimalism /// </summary> /// <param name="scaleStr"></param> /// <param name="fromStyle"></param> /// <returns></returns> public static int CastToDecimalism(this string scaleStr, ScaleStyles fromStyle = ScaleStyles.Hexadecimal) { return(fromStyle switch { ScaleStyles.Binary => BinaryConverter.ToDecimalism(scaleStr), ScaleStyles.Hexadecimal => HexadecimalConverter.ToDecimalism(scaleStr), _ => StringIntDeterminer.To(scaleStr) });
static void Main(string[] args) { int[] cipher = new[] { 1, 1, 2, 3, 5, 8, 13 }; Console.WriteLine("Please enter your text"); var fullName = Console.ReadLine(); Console.WriteLine("Your entered text is: " + fullName); BinaryConverter binaryConverter = new BinaryConverter(); string binaryValue = binaryConverter.ConvertTo(fullName); Console.WriteLine($"{fullName} as Binary: {binaryValue}"); Console.WriteLine("Converting value from Binary to ASCII :"); Console.WriteLine($"Binary Value:{binaryValue}" + "\n" + $"The text converted from Binary to text: {binaryConverter.ConvertBinaryToString(binaryValue)}"); HexadecimalConverter hex = new HexadecimalConverter(); string StringToHex = hex.ConvertTo(fullName); Console.WriteLine($"{fullName} as Hexadecimal Value is : {StringToHex}"); Console.WriteLine($"{StringToHex} is Hexadecimal for ASCII: {hex.ConveryFromHexToASCII(StringToHex)}"); string nameBase64Encoded = Models.Base64.StringToBase64(fullName); Console.WriteLine("The text converted to the Base64 is :" + nameBase64Encoded); string nameBase64Decoded = Models.Base64.Base64ToString(nameBase64Encoded); Console.WriteLine($"The Text value of {nameBase64Encoded} is :" + nameBase64Decoded); Console.WriteLine("for the conversion of the fullname to bytearray:"); byte[] fullnamebytes = Encoding.ASCII.GetBytes(fullName); foreach (byte b in fullnamebytes) { Console.WriteLine("Converted text in the byte[]: " + b); } Console.WriteLine("Please Enter the Text That need to be DeepEncrypt "); string unicodeString = Console.ReadLine(); int encryptionDepth = 10; string cipherasString = String.Join(",", cipher.Select(x => x.ToString())); Encrypter encrypter = new Encrypter(unicodeString, cipher, encryptionDepth); string nameEncryptWithCipher = Encrypter.EncryptWithCipher(unicodeString, cipher); Console.WriteLine($"Encrypted once using the cipher {{{cipherasString}}} {nameEncryptWithCipher}"); string nameDecryptWithCipher = Encrypter.DecryptWithCipher(nameEncryptWithCipher, cipher); Console.WriteLine($"Decrypted once using the cipher {{{cipherasString}}} {nameDecryptWithCipher}"); }
/// Asks user for word, prints Hex value of that word static void PrintHexfromASCII() { Console.WriteLine("\nPlease enter a word to covert to Hexadecimal: "); string username = Console.ReadLine(); HexadecimalConverter hexconverter = new HexadecimalConverter(); string hexname = hexconverter.ConvertTo(username); Console.WriteLine($"The Hex value of {username} is {hexname}"); }
static void Main(string[] args) { string name = "Vrushabh Patel"; HexadecimalConverter hexadecimalConverter = new HexadecimalConverter(); string hexadecimalValue = hexadecimalConverter.ConvertTo(name); Console.WriteLine($"{name} as Hexadecimal: {hexadecimalValue}"); Console.WriteLine($"{name} from Hexadecimal to ASCII: {hexadecimalConverter.ConveryFromHexToASCII(hexadecimalValue)}"); }
private static string StringToHex(String name) { HexadecimalConverter hexadecimalConverter = new HexadecimalConverter(); string hexadecimalValue = hexadecimalConverter.ConvertTo(name); Console.WriteLine($"{name} as Hexadecimal: {hexadecimalValue}"); return(hexadecimalValue); }
static void Main(string[] args) { string name; //getting name Console.WriteLine("enter your name: "); name = Console.ReadLine(); string unicodeString = name; //binary conversion BinaryConverter binaryConverter = new BinaryConverter(); string binaryValue = binaryConverter.ConvertTo(name); Console.WriteLine($"{name} as Binary: {binaryValue}"); Console.WriteLine($"{name} from Binary to ASCII: {binaryConverter.ConvertBinaryToString(binaryValue)}"); HexadecimalConverter hexadecimalConverter = new HexadecimalConverter(); string hexadecimalValue = hexadecimalConverter.ConvertTo(name); Console.WriteLine($"{name} as Hexadecimal: {hexadecimalValue}"); Console.WriteLine($"{name} from Hexadecimal to ASCII: {hexadecimalConverter.ConveryFromHexToASCII(hexadecimalValue)}"); int[] cipher = new[] { 1, 1, 2, 3, 5, 8, 13 }; //Fibonacci Sequence string cipherasString = String.Join(",", cipher.Select(x => x.ToString())); //FOr display int encryptionDepth = 20; encrypter encrypter = new encrypter(unicodeString, cipher, encryptionDepth); //Single Level Encrytion string nameEncryptWithCipher = encrypter.EncryptWithCipher(unicodeString, cipher); Console.WriteLine($"Encrypted once using the cipher {{{cipherasString}}} {nameEncryptWithCipher}"); string nameDecryptWithCipher = encrypter.DecryptWithCipher(nameEncryptWithCipher, cipher); Console.WriteLine($"Decrypted once using the cipher {{{cipherasString}}} {nameDecryptWithCipher}"); //Deep Encrytion string nameDeepEncryptWithCipher = encrypter.DeepEncryptWithCipher(unicodeString, cipher, encryptionDepth); Console.WriteLine($"Deep Encrypted {encryptionDepth} times using the cipher {{{cipherasString}}} {nameDeepEncryptWithCipher}"); string nameDeepDecryptWithCipher = encrypter.DeepDecryptWithCipher(nameDeepEncryptWithCipher, cipher, encryptionDepth); Console.WriteLine($"Deep Decrypted {encryptionDepth} times using the cipher {{{cipherasString}}} {nameDeepDecryptWithCipher}"); //Base64 Encoded Console.WriteLine($"Base64 encoded {unicodeString} {encrypter.Base64}"); string base64toPlainText = encrypter.Base64ToString(encrypter.Base64); Console.WriteLine($"Base64 decoded {encrypter.Base64} {base64toPlainText}"); }
private static void AllInONeConvertor(String name) { BinaryConverter binaryConverter = new BinaryConverter(); string binaryValue = binaryConverter.ConvertTo(name); Console.WriteLine($"{name} as Binary: {binaryValue}"); Console.WriteLine($"{name} from Binary to ASCII: {binaryConverter.ConvertBinaryToString(binaryValue)}"); HexadecimalConverter hexadecimalConverter = new HexadecimalConverter(); string hexadecimalValue = hexadecimalConverter.ConvertTo(name); Console.WriteLine($"{name} as Hexadecimal: {hexadecimalValue}"); Console.WriteLine($"{name} from Hexadecimal to ASCII: {hexadecimalConverter.ConveryFromHexToASCII(hexadecimalValue)}"); Base64Convertor base64Converter = new Base64Convertor(); string base64Value = base64Converter.StringToBase64(name); Console.WriteLine($"{name} as Base64: {base64Value}"); Console.WriteLine($"{name} from base64 to ASCII: {base64Converter.Base64ToString(base64Value)}"); int[] cipher = new[] { 1, 1, 2, 3, 5, 8, 13 }; //Fibonacci Sequence string cipherasString = String.Join(",", cipher.Select(x => x.ToString())); //FOr display int encryptionDepth = 20; Encrypter encrypter = new Encrypter(name, cipher, encryptionDepth); //Single Level Encrytion string nameEncryptWithCipher = Encrypter.EncryptWithCipher(name, cipher); Console.WriteLine($"Encrypted once using the cipher {{{cipherasString}}} {nameEncryptWithCipher}"); string nameDecryptWithCipher = Encrypter.DecryptWithCipher(nameEncryptWithCipher, cipher); Console.WriteLine($"Decrypted once using the cipher {{{cipherasString}}} {nameDecryptWithCipher}"); //Deep Encrytion string nameDeepEncryptWithCipher = Encrypter.DeepEncryptWithCipher(name, cipher, encryptionDepth); Console.WriteLine($"Deep Encrypted {encryptionDepth} times using the cipher {{{cipherasString}}} {nameDeepEncryptWithCipher}"); string nameDeepDecryptWithCipher = Encrypter.DeepDecryptWithCipher(nameDeepEncryptWithCipher, cipher, encryptionDepth); Console.WriteLine($"Deep Decrypted {encryptionDepth} times using the cipher {{{cipherasString}}} {nameDeepDecryptWithCipher}"); //Base64 Encoded Console.WriteLine($"Base64 encoded {name} {encrypter.Base64}"); string base64toPlainText = Encrypter.Base64ToString(encrypter.Base64); Console.WriteLine($"Base64 decoded {encrypter.Base64} {base64toPlainText}"); }
private static string HexToASCII(String name) { HexadecimalConverter hexadecimalConverter = new HexadecimalConverter(); string hexadecimalValue = hexadecimalConverter.ConvertTo(name); Console.WriteLine($"{name} from Hexadecimal to ASCII: {hexadecimalConverter.ConveryFromHexToASCII(hexadecimalValue)}"); String converted = hexadecimalConverter.ConveryFromHexToASCII(hexadecimalValue); return(converted); }
public void WhenIInputTheValue(int decimalInt) { var converter = new HexadecimalConverter(); try { _result = converter.ConvertToHexadecimal(decimalInt); } catch (Exception e) { _exception = e; } }
static void Main(string[] args) { Console.WriteLine("Type yout full name : "); string Name = Console.ReadLine(); BinaryConverter binaryConverter = new BinaryConverter(); string binaryValue = binaryConverter.ConvertTo(Name); Console.WriteLine($"\n{Name} as Binary: {binaryValue}"); Console.WriteLine("\nCopy and Paste your Binary full name here : "); string binvalue = Console.ReadLine(); Console.WriteLine($"\n{binvalue} from Binary to ASCII: {binaryConverter.ConvertBinaryToString(binaryValue)}"); HexadecimalConverter hexadecimalConverter = new HexadecimalConverter(); string hexadecimalValue = hexadecimalConverter.ConvertTo(Name); Console.WriteLine($"\n{Name} as Hexadecimal: {hexadecimalValue}"); Console.WriteLine($"\n{Name} from Hexadecimal to ASCII: {hexadecimalConverter.ConveryFromHexToASCII(hexadecimalValue)}"); string nameBase64Encoded = StringToBase64(Name); Console.WriteLine($"\n{Name} as Base64: {nameBase64Encoded}"); string nameBase64Decoded = Base64ToString(nameBase64Encoded); Console.WriteLine($"\n{Name} from Base64 to ASCII: {nameBase64Decoded}"); int[] cipher = new[] { 1, 1, 2, 3, 5, 8, 13 }; //Fibonacci Sequence string cipherasString = String.Join(",", cipher.Select(x => x.ToString())); //FOr display int encryptionDepth = 20; Encrypter encrypter = new Encrypter(Name, cipher, encryptionDepth); //Deep Encrytion string nameDeepEncryptWithCipher = Encrypter.DeepEncryptWithCipher(Name, cipher, encryptionDepth); Console.WriteLine($"\nDeep Encrypted {encryptionDepth} times using the cipher {{{cipherasString}}} {nameDeepEncryptWithCipher}"); string nameDeepDecryptWithCipher = Encrypter.DeepDecryptWithCipher(nameDeepEncryptWithCipher, cipher, encryptionDepth); Console.WriteLine($"\nDeep Decrypted {encryptionDepth} times using the cipher {{{cipherasString}}} {nameDeepDecryptWithCipher}"); }
static void Main(string[] args) { Console.WriteLine("Hello Human!"); Console.WriteLine("Type your name to see how is it in my eyes!"); Create an instance of UserInput object UserInputs userInputs = new UserInputs(); userInputs.FullName = Console.ReadLine(); BinaryConverter binaryConverter = new BinaryConverter(); string binaryValue = binaryConverter.ConvertTo(userInputs.FullName); Console.WriteLine($"{userInputs.FullName} what I see as Binary: {binaryValue}"); Console.WriteLine("Now try the binary!"); userInputs.binary = Console.ReadLine(); Console.WriteLine($"{userInputs.binary} from Binary to ASCII: {binaryConverter.ConvertBinaryToString(binaryValue)}"); Console.WriteLine("Press é to see its hexadecimal!"); string input = userInputs.FullName; string result = String.Concat(input.Select(x => ((int)x).ToString("x"))); Console.WriteLine($"{userInputs.FullName} from ASCI to hexadecimal : {result}"); ConsoleKeyInfo key = Console.ReadKey(); //this code takes user input Console.Write(key.KeyChar); userInputs.Character = key.KeyChar; if (userInputs.Character == 'é') { HexadecimalConverter hexadecimalConverter = new HexadecimalConverter(); string hexavalue = hexadecimalConverter.ConvertTo(userInputs.FullName); Console.WriteLine($"{userInputs.FullName} and this is the hexaform: {hexavalue}"); } else { Console.WriteLine("opss so you don't want to learn it hexadeciaml!!"); } }
/// Asks users for Hex, prints Ascii value static void PrintASCIIfromHex() { try { Console.WriteLine("\nPlease enter Hex to print as ASCII (visible characters from 021 to 07e): "); string userhex = Console.ReadLine(); HexadecimalConverter hexconverter = new HexadecimalConverter(); string hexname = hexconverter.ConveryFromHexToASCII(userhex); Console.WriteLine($"The Hex value of {userhex} is {hexname}"); } catch { Console.WriteLine("Please try again: "); string userhex = Console.ReadLine(); HexadecimalConverter hexconverter = new HexadecimalConverter(); string hexname = hexconverter.ConveryFromHexToASCII(userhex); Console.WriteLine($"The Hex value of {userhex} is {hexname}"); } }
static void Main(string[] args) { string val; Console.Write("Enter a name: "); val = Console.ReadLine(); BinaryConverter binaryConverter = new BinaryConverter(); string binaryValue = binaryConverter.ConvertTo(val); Console.WriteLine($"{val} as Binary: {binaryValue}"); Console.WriteLine($"{val} from Binary to ASCII: {binaryConverter.ConvertBinaryToString(binaryValue)}"); HexadecimalConverter hexadecimalConverter = new HexadecimalConverter(); string hexadecimalValue = hexadecimalConverter.ConvertTo(val); Console.WriteLine($"{val} as Hexadecimal: {hexadecimalValue}"); Console.WriteLine($"{val} from Hexadecimal to ASCII: {hexadecimalConverter.ConveryFromHexToASCII(hexadecimalValue)}"); int[] cipher = new[] { 1, 1, 2, 3, 5, 8, 13 }; //Fibonacci Sequence string cipherasString = String.Join(",", cipher.Select(x => x.ToString())); //FOr display int encryptionDepth = 20; Encrypter encrypter = new Encrypter(val, cipher, encryptionDepth); Console.WriteLine($"Base64 encoded {val} {encrypter.Base64}"); string base64toPlainText = Encrypter.Base64ToString(encrypter.Base64); Console.WriteLine($"Base64 decoded {encrypter.Base64} {base64toPlainText}"); //Deep Encrytion string nameDeepEncryptWithCipher = Encrypter.DeepEncryptWithCipher(val, cipher, encryptionDepth); Console.WriteLine($"Deep Encrypted {encryptionDepth} times using the cipher {{{cipherasString}}} {nameDeepEncryptWithCipher}"); string nameDeepDecryptWithCipher = Encrypter.DeepDecryptWithCipher(nameDeepEncryptWithCipher, cipher, encryptionDepth); Console.WriteLine($"Deep Decrypted {encryptionDepth} times using the cipher {{{cipherasString}}} {nameDeepDecryptWithCipher}"); }
public void ToHexadecimal_WhenNumberEquals42_Returns2A() { var convert = new HexadecimalConverter(); string result = convert.ToHexadecimal(42); Assert.AreEqual("2A", result); }
/// <summary> /// To binary /// </summary> /// <param name="hex"></param> /// <returns></returns> public static string CastToBinary(this string hex) => HexadecimalConverter.ToBinary(hex);
public void Ctor_HasBase16Values() { var convert = new HexadecimalConverter(); CollectionAssert.AreEqual(this.base16Values, convert.Values); }
public void ToHexadecimal_WhenNumberIsLessThan0_ThrowsIndexOutOfRangeException() { var convert = new HexadecimalConverter(); string result = convert.ToHexadecimal(-1); }
static void Main(string[] args) { Console.WriteLine("Enter your full name: "); string name = Console.ReadLine(); int[] cipher = new[] { 1, 1, 2, 3, 5, 8, 13 }; //Fibonacci Sequence string cipherasString = String.Join(",", cipher.Select(x => x.ToString())); //FOr display int encryptionDepth = 20; //binary conversion BinaryConverter binaryConverter = new BinaryConverter(); string binaryValue = binaryConverter.ConvertTo(name); Console.WriteLine($"{name} as Binary: {binaryValue}"); Console.WriteLine("Enter Binary Version of your Name: "); string binaryName = Console.ReadLine(); Console.WriteLine($"{binaryName} from Binary to ASCII: {binaryConverter.ConvertBinaryToString(binaryValue)}"); //hex conversion HexadecimalConverter hexadecimalConverter = new HexadecimalConverter(); string hexadecimalValue = hexadecimalConverter.ConvertTo(name); Console.WriteLine($"{name} as Hexadecimal: {hexadecimalValue}"); Console.WriteLine($"{name} from Hexadecimal to ASCII: {hexadecimalConverter.ConveryFromHexToASCII(hexadecimalValue)}"); //base64 conversion Base64Converter base64Converter = new Base64Converter(); string nameBase64Encoded = base64Converter.StringToBase64(name); Console.WriteLine($"{name} as Base64: {nameBase64Encoded}"); //Output the decoded Base64 string string nameBase64Decoded = base64Converter.Base64ToString(nameBase64Encoded); Console.WriteLine($"{name} from Base64 to ASCIII: {nameBase64Decoded}"); //ciphering Encrypter encrypter = new Encrypter(name, cipher, encryptionDepth); //Single Level Encrytion string nameEncryptWithCipher = Encrypter.EncryptWithCipher(name, cipher); Console.WriteLine($"Encrypted once using the cipher {{{cipherasString}}} {nameEncryptWithCipher}"); string nameDecryptWithCipher = Encrypter.DecryptWithCipher(nameEncryptWithCipher, cipher); Console.WriteLine($"Decrypted once using the cipher {{{cipherasString}}} {nameDecryptWithCipher}"); //Deep Encrytion string nameDeepEncryptWithCipher = Encrypter.DeepEncryptWithCipher(name, cipher, encryptionDepth); Console.WriteLine($"Deep Encrypted {encryptionDepth} times using the cipher {{{cipherasString}}} {nameDeepEncryptWithCipher}"); string nameDeepDecryptWithCipher = Encrypter.DeepDecryptWithCipher(nameDeepEncryptWithCipher, cipher, encryptionDepth); Console.WriteLine($"Deep Decrypted {encryptionDepth} times using the cipher {{{cipherasString}}} {nameDeepDecryptWithCipher}"); //Base64 Encoded Console.WriteLine($"Base64 encoded {name} {encrypter.Base64}"); string base64toPlainText = Encrypter.Base64ToString(encrypter.Base64); Console.WriteLine($"Base64 decoded {encrypter.Base64} {base64toPlainText}"); }
static void Main(string[] args) { Console.WriteLine("**********************BINARY CONVERSION**********************"); Console.WriteLine("Enter your name:"); string name = Console.ReadLine(); BinaryConverter binaryConverter = new BinaryConverter(); string binaryValue = binaryConverter.ConvertTo(name); Console.WriteLine($"{name} as Binary: {binaryValue}"); Console.WriteLine("Enter the binary version of your name:"); string binaryName = Console.ReadLine(); Console.WriteLine($"Binary code entered in ASCII format: {binaryConverter.ConvertBinaryToString(binaryValue)}"); Console.WriteLine("**********************HEXADECIMAL CONVERSION**********************"); HexadecimalConverter hexadecimalConverter = new HexadecimalConverter(); string hexadecimalValue = hexadecimalConverter.ConvertTo(name); Console.WriteLine($"{name} as Hexadecimal: {hexadecimalValue}"); Console.WriteLine($"{name} from Hexadecimal to ASCII: {hexadecimalConverter.ConveryFromHexToASCII(hexadecimalValue)}"); Console.WriteLine("**********************BASE64 CONVERSION**********************"); Base64Converter base64Converter = new Base64Converter(); string base64Value = base64Converter.StringToBase64(name); Console.WriteLine($"{name} as Base64: {base64Value}"); Console.WriteLine("**********************ENCRYPTION AND DECRYPTION**********************"); //Output the decoded Base64 string string nameBase64Decoded = base64Converter.Base64ToString(base64Value); //Console.WriteLine(nameBase64Decoded); Console.WriteLine($"{name} from Base64 to ASCII: {nameBase64Decoded}"); //string unicodeString = "This string contains the unicode character Pi (\u03a0)"; int[] cipher = new[] { 0, 2, 4, 6, 8, 10, 12 }; //even numbers string cipherasString = String.Join(",", cipher.Select(x => x.ToString())); //FOr display int encryptionDepth = 20; string myName = "VARGHESE"; Encrypter encrypter = new Encrypter(myName, cipher, encryptionDepth); ////Single Level Encrytion //string nameEncryptWithCipher = Encrypter.EncryptWithCipher(unicodeString, cipher); //Console.WriteLine($"Encrypted once using the cipher {{{cipherasString}}} {nameEncryptWithCipher}"); //string nameDecryptWithCipher = Encrypter.DecryptWithCipher(nameEncryptWithCipher, cipher); //Console.WriteLine($"Decrypted once using the cipher {{{cipherasString}}} {nameDecryptWithCipher}"); //Deep Encrytion string nameDeepEncryptWithCipher = Encrypter.DeepEncryptWithCipher(myName, cipher, encryptionDepth); Console.WriteLine($"Deep Encrypted {encryptionDepth} times using the cipher {{{cipherasString}}} {nameDeepEncryptWithCipher}"); string nameDeepDecryptWithCipher = Encrypter.DeepDecryptWithCipher(nameDeepEncryptWithCipher, cipher, encryptionDepth); Console.WriteLine($"Deep Decrypted {encryptionDepth} times using the cipher {{{cipherasString}}} {nameDeepDecryptWithCipher}"); //Base64 Encoded //Console.WriteLine($"Base64 encoded {myName} {encrypter.Base64}"); //string base64toPlainText = Encrypter.Base64ToString(encrypter.Base64); //Console.WriteLine($"Base64 decoded {encrypter.Base64} {base64toPlainText}"); }
public void ToHexadecimal_WhenNumberIsGreaterThan255_ThrowsIndexOutOfRangeException() { var convert = new HexadecimalConverter(); string result = convert.ToHexadecimal(256); }
static void Main(string[] args) { // string unicodeString = "This string contains the unicode character Pi (\u03a0)"; Console.WriteLine("****************************ASCII to Binary************************"); Console.WriteLine("Enter Your Name Please:"); String HexaCoding = Console.ReadLine(); BinaryConverter binaryConverter = new BinaryConverter(); string binaryValue = binaryConverter.ConvertTo(HexaCoding); Console.WriteLine($"{HexaCoding} as Binary: {binaryValue}"); Console.WriteLine("****************************Binary to ASCII************************"); Console.WriteLine("Enter binary version of your name"); String binary = Console.ReadLine(); Console.WriteLine($"{binary} from Binary to ASCII: {binaryConverter.ConvertBinaryToString(binary)}"); Console.WriteLine("****************************ASCII to Hexa Decimal************************"); Console.WriteLine("This is for Hexa.../n Enter Your Name Please:"); String hexaCoding = Console.ReadLine(); HexadecimalConverter hexadecimalConverter = new HexadecimalConverter(); string hexValue = hexadecimalConverter.ConvertTo(HexaCoding); Console.WriteLine($"{HexaCoding} as Hexa: {hexValue}"); Console.WriteLine("****************************Hexa Decimal to ASCII************************"); Console.WriteLine("Enter Hexa Decimal version of your name"); String hexa = Console.ReadLine(); Console.WriteLine($"{hexa} from Hexa Decimal to ASCII: {hexadecimalConverter.ConveryFromHexToASCII(hexa)}"); int[] cipher = new[] { 1, 1, 2, 3, 5, 8, 13 }; //Fibonacci Sequence string cipherasString = String.Join(",", cipher.Select(x => x.ToString())); //FOr display int encryptionDepth = 20; Encrypter encrypter = new Encrypter(HexaCoding, cipher, encryptionDepth); Console.WriteLine("****************************ASCII to Base64************************"); Console.WriteLine($"Base64 encoded {HexaCoding} {encrypter.Base64}"); Console.WriteLine("****************************Base64 to ASCII************************"); string base64toPlainText = Encrypter.Base64ToString(encrypter.Base64); Console.WriteLine($"Base64 decoded {encrypter.Base64} {base64toPlainText}"); //Single Level Encrytion //string nameEncryptWithCipher = Encrypter.EncryptWithCipher(HexaCoding, cipher); //Console.WriteLine($"Encrypted once using the cipher {{{cipherasString}}} {nameEncryptWithCipher}"); //string nameDecryptWithCipher = Encrypter.DecryptWithCipher(nameEncryptWithCipher, cipher); //Console.WriteLine($"Decrypted once using the cipher {{{cipherasString}}} {nameDecryptWithCipher}"); //Deep Encrytion with encryptionDepth 20 string nameDeepEncryptWithCipher = Encrypter.DeepEncryptWithCipher(HexaCoding, cipher, encryptionDepth); Console.WriteLine($"Deep Encrypted {encryptionDepth} times using the cipher {{{cipherasString}}} {nameDeepEncryptWithCipher}"); string nameDeepDecryptWithCipher = Encrypter.DeepDecryptWithCipher(nameDeepEncryptWithCipher, cipher, encryptionDepth); Console.WriteLine($"Deep Decrypted {encryptionDepth} times using the cipher {{{cipherasString}}} {nameDeepDecryptWithCipher}"); }