private void SingleSignonCode(string ClinicKey, string UserID, out string SingleSignOnCode, out string SingleSignOnUserIdVerify, bool IsUrlEncoding) { string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url); using (Utils utility = new Utils()) { utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod()); } string base64String; SingleSignOnCode = ""; SingleSignOnUserIdVerify = ""; string str = EncryptionCommon.CreatePhrase(); byte[] bytes = EncodingUtility.GetBytes(string.Concat(str, this.Key), EncodingUtility.encodingOptions.UTF8); SHA512Managed sHA512Managed = new SHA512Managed(); try { base64String = Convert.ToBase64String(sHA512Managed.ComputeHash(bytes)); } finally { if (sHA512Managed != null) { ((IDisposable)sHA512Managed).Dispose(); } } if (base64String.Substring(base64String.Length - 2, 2).Equals("==")) { base64String = base64String.Substring(0, base64String.Length - 2); } SingleSignOnCode = (IsUrlEncoding ? HttpUtility.UrlEncode(string.Concat(str, base64String)) : string.Concat(str, base64String)); base64String = ""; SingleSignOnUserIdVerify = string.Concat(UserID, str.Substring(0, 22), this.Key); bytes = EncodingUtility.GetBytes(SingleSignOnUserIdVerify, EncodingUtility.encodingOptions.UTF8); sHA512Managed = new SHA512Managed(); try { base64String = Convert.ToBase64String(sHA512Managed.ComputeHash(bytes)); } finally { if (sHA512Managed != null) { ((IDisposable)sHA512Managed).Dispose(); } } if (base64String.Substring(base64String.Length - 2, 2).Equals("==")) { base64String = base64String.Substring(0, base64String.Length - 2); } SingleSignOnUserIdVerify = (IsUrlEncoding ? HttpUtility.UrlEncode(base64String) : base64String); }