private static string SignVals(string key, DuoWebRequest Request, string prefix, Int64 expire, DateTime current_time)
        {
            Int64 ts = (Int64)(current_time - new DateTime(1970, 1, 1)).TotalSeconds;

            expire = ts + expire;

            string val    = Request.USERNAME + "|" + Request.IKEY + "|" + expire.ToString();
            string cookie = prefix + "|" + Encode64(val);

            string sig = HmacSign(key, cookie);

            return(cookie + "|" + sig);
        }
        public static string DuoWeb_SignRequest(DuoWebRequest Request)
        {
            string   duo_sig;
            string   app_sig;
            DateTime CurrentDate = DateTime.UtcNow;

            // simple validation checking for the send call - PMT 01/3/2020
            if (Request.USERNAME == "")
            {
                return(Error.USER);
            }
            if (Request.USERNAME.Contains("|"))
            {
                return(Error.USER);
            }
            if (Request.IKEY.Length != KeyLength.IKEY)
            {
                return(Error.IKEY);
            }
            if (Request.SKEY.Length != KeyLength.SKEY)
            {
                return(Error.SKEY);
            }
            if (Request.AKEY.Length < KeyLength.AKEY)
            {
                return(Error.AKEY);
            }

            try
            {
                // Create Duo Signature and Application Signature
                duo_sig = SignVals(Request.SKEY, Request, DuoProperty.DUO_PREFIX, DuoProperty.DUO_EXPIRE, CurrentDate);
                app_sig = SignVals(Request.AKEY, Request, DuoProperty.APP_PREFIX, DuoProperty.APP_EXPIRE, CurrentDate);
            }
            catch (Exception e)
            {
                //Handle exception if th request fails. Show message to user and show the Exception error
                return(Error.UNKNOWN + " (" + e.Message + ") ");
            }

            //Combine both Signatures for the request to the iframe
            return(duo_sig + ":" + app_sig);
        }