using System;
using System.Net.Sockets;
using System.IO;
using System.Security.Cryptography;
public class Test
{
public static void Main()
{
string secret = "shienshenlhq";
string placa = "PGM1833";
string placaHash;
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
byte[] keyByte = encoding.GetBytes(secret);
byte[] messageBytes = encoding.GetBytes(placa);
using (HMACSHA1 hmacsha1 = new HMACSHA1(keyByte))
{
byte[] hashmessage = hmacsha1.ComputeHash(messageBytes);
placaHash = (HexStringFromBytes(hashmessage));
Console.WriteLine(placaHash);
}
string postData = "GT-S1312LAndroid1.1.14.1.4aplicativo177.206.169.90" + placaHash + "-3-38" + placa + "\n/sinesp-cidadao/ConsultaPlaca HTTP/1.1\r\r\n";
byte[] bytes = Encoding.UTF8.GetBytes(postData);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://s...content-available-to-author-only...v.br/sinesp-cidadao/ConsultaPlacaNovo27032014");
request.ProtocolVersion = HttpVersion.Version11;
request.Method = "POST";
request.Host = "sinespcidadao.sinesp.gov.br";
request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
request.ContentLength = bytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.Length);
WebResponse response = request.GetResponse();
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
var result = reader.ReadToEnd();
stream.Dispose();
reader.Dispose();
Console.WriteLine(result.ToString());
Console.ReadKey();
}
public static string HexStringFromBytes(byte[] bytes)
{
var sb = new StringBuilder();
foreach (byte b in bytes)
{
var hex = b.ToString("x2");
sb.Append(hex);
}
return sb.ToString();
}
}