12,401,189 members (38,676 online)
Rate this:
See more: , +
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 1-Nov-12 22:07pm
Deenuji3.9K
Nelek 2-Nov-12 4:38am

Please try not to re-ask questions. You can use the "improve question" widget to edit your texts.

Rate this:

## Solution 1

Binary, octal and hex are all the same in this context - you just need to convert the string to bytes:
```string s = "Hello!";
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(s);```
Rate this:

## Solution 2

1st write this function on your page:

```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;

Top Experts
Last 24hrsThis month
 OriginalGriff 300 Karthik Bangalore 170 ppolymorphe 155 Richard Deeming 130 0x01AA 90
 OriginalGriff 6,963 ppolymorphe 2,950 Karthik Bangalore 2,737 F-ES Sitecore 2,082 Richard MacCutchan 2,077