I have a SQL Server database with a binary(64)
column housing a password. I am using a C# ASP.NET API to query the data and return the data as a string back to my C# code.
In SQL Server the password is
0x507572706C6500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
In my C# the password as a string is
UHVycGxlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
And in plain text the password is: Purple
My question at hand is how can I use C# to "parse" the returned string and convert it to readable format?
I tried the below syntax, but I get an error of... What would be the proper way to "parse" the hashed password into plain text?
Could not find any recognizable digits
public class SQLData
{
public string pass { get; set; }
}
public static string BinaryToString(string data)
{
List<Byte> byteList = new List<Byte>();
for (int i = 0; i < data.Length; i += 8)
{
byteList.Add(Convert.ToByte(data.Substring(i, 8), 2));
}
return Encoding.ASCII.GetString(byteList.ToArray());
}
private void btnPullData_Click(object sender, EventArgs e)
{
string URI = "http://192.168.5.200:8888/api/Xamarin?email=jose%40gmail.com;
using (var webClient = new System.Net.WebClient())
{
var json = webClient.DownloadString(URI);
var message = JsonConvert.DeserializeObject<SQLData>(json);
string clearpass = BinaryToString(message.pass);
MessageBox.Show(clearpass);
}
}