Exemple #1
0
        public void SignRequest(ref HttpWebRequest Request)
        {
            TimeSpan diff      = DateTime.UtcNow - (new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc));
            uint     timestamp = (uint)Math.Floor(diff.TotalSeconds); // Seconds since 1970
            string   data      = timestamp.ToString();

            Chilkat.PrivateKey privkey1 = new Chilkat.PrivateKey();
            privkey1.LoadPem(mykey);
            Chilkat.Rsa rsa1    = new Chilkat.Rsa();
            bool        success = rsa1.UnlockComponent("HAFSJORSA_K36nxU3n1Yui");

            success           = rsa1.ImportPrivateKey(privkey1.GetXml());
            rsa1.EncodingMode = "base64";
            rsa1.Charset      = "ANSI";
            rsa1.LittleEndian = false;
            rsa1.OaepPadding  = false;

            string s_mysecre = data + mysecret;

            char[] c_mysecre = s_mysecre.ToCharArray();
            byte[] b_mysecre = System.Text.Encoding.GetEncoding("windows-1252").GetBytes(c_mysecre);
            string hexSig    = rsa1.SignBytesENC(b_mysecre, "sha-1");

            Request.Headers.Add("timestamp", data);
            Request.Headers.Add("signed", hexSig);
        }