
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Net.Security;
using System.Collections;
using System.Net.Sockets;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Net;
using System.Security.Cryptography;

namespace ResiptPage
{
    public partial class ChechSSL : System.Web.UI.Page
    {



        protected void Page_Load(object sender, EventArgs e)
        {

        }
        private string createfpHash(string signacher)
        {
            string key = "eoXaEm2LUnz2OiyQ";
            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();

            byte[] keyByte = encoding.GetBytes(key);

            HMACMD5 hmacmd5 = new HMACMD5(keyByte);

            byte[] messageBytes = encoding.GetBytes(signacher);

            byte[] hashmessage = hmacmd5.ComputeHash(messageBytes);

            return signacher = ByteToString(hashmessage);



        }
        private string ByteToString(byte[] buff)
        {
            string sbinary = "";

            for (int i = 0; i < buff.Length; i++)
            {
                sbinary += buff[i].ToString("X2"); // hex format
            }
            return (sbinary);
        }


        protected void Button2_Click(object sender, EventArgs e)
        {
            using (var client = new WebClient())
            {
                var datatopost = Encoding.Default.GetBytes(""); //encoding.default.getbytes("param1=value1&param2=value2");
                string emza =
createfpHash("737218180013^577^1265011576^1^Rial");
                var result = client.UploadData

(@"https://damoon.bsi.ir/DamoonVerificationController?x_description=damoon
test&x_login=737218180013&x_fp_sequence=577&x_fp_timestamp=1265011576&x_amount=1&x_currency_code=Rial&x_fp_hash="
+
                   emza, "post", datatopost);
                // do something with the result
                string dd = Encoding.ASCII.GetString(result);
                Response.Write("<Div>");

                Response.Write(dd.Remove(dd.IndexOf("<")));

                Response.Write("</Div>");
                string[] arrayofdata =
dd.Remove(dd.IndexOf("<")).Split(new char[2] { '&','=' });
                foreach (string ssss in arrayofdata)
                {
                    Response.Write(ssss);
                    Response.Write("</br>");
                }
            }
        }
    }
}
