Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
How to convert text to binary and octal and hexadecimal in asp.net???? actually i want to generate some secret key and public key using given upload text????
Posted
Comments
Nelek 2-Nov-12 4:38am    
Please try not to re-ask questions. You can use the "improve question" widget to edit your texts.

Binary, octal and hex are all the same in this context - you just need to convert the string to bytes:
C#
string s = "Hello!";
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(s);
 
Share this answer
 
1st write this function on your page:

C#
public static string ConvertToBin(string asciiString)
   {
       StringBuilder sb = new StringBuilder();
       foreach (string letter in asciiString.Select(c => Convert.ToString(c, 8)))
       {
           sb.Append(letter);
       }
       return sb.ToString().Substring(0,5);
   }

then write this coding where u want to show ur encrypt key like textbox means write like this it show 5 digit encrypt key:

TextBox1.Text = ConvertToBin(a);
TextBox2.Text = ConvertToBin(content.Substring(content.Length - 5, 5)); RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
TextBox3.Text = ConvertToBin(rsa.ToXmlString(true).Substring(15, 5));
TextBox4.Text = ConvertToBin(rsa.ToXmlString(true).Substring(15, 5));
TextBox5.Text = ConvertToBin(rsa.ToXmlString(true).Substring(22, 5));
TextBox6.Text = content;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900