Kyle Undefined
01-24-2010, 06:45 AM
C# Speedy Text Conversion
Current Version : 1.0
Last Updated : 1/24/2010
Last Released : 1/24/2010
I was bored so I made a quick Text to Binary and back conversion program. I plan on extending this to more than Binary.
This is my first C# application, but I've written countless VB ones, I just think I could get some good feedback for this here :) I have a link to the program and have the source below, since I know a lot of you would want to see it ;) It was pretty simple to make, maybe just an hours since I had to look up a few things first.
-=FEATURES=-
- Converts Text to Binary
- Converts Binary to Text
-=PLANNED FEATURES=-
- Hex Conversion
- Base64 Conversion
- Dec/Char Conversion
- Maybe MD5 hash
- Suggestions?
Please Hate/Rate/Comment :)
Check out the Programs link in my sig to follow this development!
Program Link -> http://drop.io/kdhvjiy
using System;
using System.Data;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Globalization;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace Form1 {
public partial class BinaryTextForm : Form {
public BinaryTextForm() {
InitializeComponent();
}
public string TextToBinary(string Text) {
StringBuilder oReturn = new StringBuilder();
foreach (byte Character in ASCIIEncoding.ASCII.GetBytes(Text)) {
oReturn.Append(Convert.ToString(Character, 2).PadLeft(8, Convert.ToChar("0")));
oReturn.Append(" ");
}
return oReturn.ToString();
}
public string BinaryToText(string BinaryText) {
string Characters = Regex.Replace(BinaryText, "[^01]", "");
byte[] ByteArray = new byte[(Characters.Length / 8)];
for (int Index = 0; Index <= ByteArray.Length - 1; Index++) {
ByteArray[Index] = Convert.ToByte(Characters.Substring(Index * 8, 8), 2);
}
return ASCIIEncoding.ASCII.GetString(ByteArray);
}
private void txtText_TextChanged(object sender, EventArgs e) {
this.txtTextToBin.Text = TextToBinary(this.txtText.Text);
}
private void txtBinary_TextChanged(object sender, EventArgs e) {
this.txtBinToTxt.Text = BinaryToText(this.txtBinary.Text);
}
}
}
~Camo
Current Version : 1.0
Last Updated : 1/24/2010
Last Released : 1/24/2010
I was bored so I made a quick Text to Binary and back conversion program. I plan on extending this to more than Binary.
This is my first C# application, but I've written countless VB ones, I just think I could get some good feedback for this here :) I have a link to the program and have the source below, since I know a lot of you would want to see it ;) It was pretty simple to make, maybe just an hours since I had to look up a few things first.
-=FEATURES=-
- Converts Text to Binary
- Converts Binary to Text
-=PLANNED FEATURES=-
- Hex Conversion
- Base64 Conversion
- Dec/Char Conversion
- Maybe MD5 hash
- Suggestions?
Please Hate/Rate/Comment :)
Check out the Programs link in my sig to follow this development!
Program Link -> http://drop.io/kdhvjiy
using System;
using System.Data;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Globalization;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace Form1 {
public partial class BinaryTextForm : Form {
public BinaryTextForm() {
InitializeComponent();
}
public string TextToBinary(string Text) {
StringBuilder oReturn = new StringBuilder();
foreach (byte Character in ASCIIEncoding.ASCII.GetBytes(Text)) {
oReturn.Append(Convert.ToString(Character, 2).PadLeft(8, Convert.ToChar("0")));
oReturn.Append(" ");
}
return oReturn.ToString();
}
public string BinaryToText(string BinaryText) {
string Characters = Regex.Replace(BinaryText, "[^01]", "");
byte[] ByteArray = new byte[(Characters.Length / 8)];
for (int Index = 0; Index <= ByteArray.Length - 1; Index++) {
ByteArray[Index] = Convert.ToByte(Characters.Substring(Index * 8, 8), 2);
}
return ASCIIEncoding.ASCII.GetString(ByteArray);
}
private void txtText_TextChanged(object sender, EventArgs e) {
this.txtTextToBin.Text = TextToBinary(this.txtText.Text);
}
private void txtBinary_TextChanged(object sender, EventArgs e) {
this.txtBinToTxt.Text = BinaryToText(this.txtBinary.Text);
}
}
}
~Camo