コード例 #1
0
 public HMACSHA1(byte[] rgbKey)
 {
     this.hmac          = new HMACAlgorithm("SHA1");
     this.HashSizeValue = 160;
     this.Key           = rgbKey;
     this.m_disposed    = false;
 }
コード例 #2
0
 public HMACSHA1(byte[] rgbKey) : base()
 {
     hmac          = new HMACAlgorithm("SHA1");
     HashSizeValue = 160;
     Key           = rgbKey;
     m_disposed    = false;
 }
コード例 #3
0
        public static string GetResponse(string uri, string debugFileContent, string appname, string secretkey)
        {
            try
            {
                var           dt      = DateTime.Now;
                HMACAlgorithm hmac    = new HMACAlgorithm(appname, secretkey);
                var           auth    = hmac.GetAuthorizationHeader("GET", dt, uri);
                var           request = (HttpWebRequest)WebRequest.Create(uri);

                request.Method    = "GET";
                request.Date      = dt.ToUniversalTime();
                request.KeepAlive = false;
                request.Headers.Add(HttpRequestHeader.Authorization, auth);

#if DEBUG
                return(new StreamReader(debugFileContent).ReadToEnd());
#else
                using (var response = request.GetResponse())
                {
                    return(ReadResponse(response));
                }
#endif
            }
            catch (Exception ex)
            {
                logger.Error(String.Format("Error requesting (\"{0}\"): {1}", uri, ex.Message));
                throw ex;
            }
        }
コード例 #4
0
        private int GetOutputLength(HMACAlgorithm key)
        {
            if (!_dicHMACAlgorithmOutputLengths.TryGetValue(key, out var outputBytesLength))
            {
                outputBytesLength = 0;
            }

            return(outputBytesLength);
        }
コード例 #5
0
 public int this[HMACAlgorithm key]
 {
     get { return(GetOutputLength(key)); }
 }
コード例 #6
0
 public int this[HMACAlgorithm key] => GetOutputLength(key);