public static string GetHmacSha256HexText(string input, string key) { Encoding ascii = Encoding.ASCII; HMACSHA256 hmac = new HMACSHA256(ascii.GetBytes(key)); return(Pg2c2pEncryption.ByteArrayToString(hmac.ComputeHash(ascii.GetBytes(input)))); }
private dynamic GetHashData(dynamic arg) { var para = arg.body.Value as JObject; if (para == null) { return(404); } var settings = this.CurrentSite.pg2c2p; var parametersString = para.Value <string>("parameters"); if (string.IsNullOrEmpty(parametersString)) { return(404); } return(Pg2c2pEncryption.GetHmacSha256HexText(parametersString, (string)settings.authSercretKey)); }
public bool VerifyHash(string merchantId, string authSecretKey) { if (this.merchant_id != merchantId) { return(false); } var message = version + request_timestamp + merchant_id + order_id + invoice_no + currency + amount + transaction_ref + approval_code + eci + transaction_datetime + payment_channel + payment_status + channel_response_code + channel_response_desc + masked_pan + stored_card_unique_id + backend_invoice + paid_channel + paid_agent + recurring_unique_id + user_defined_1 + user_defined_2 + user_defined_3 + user_defined_4 + user_defined_5 + browser_info + ippPeriod + ippInterestType + ippInterestRate + ippMerchantAbsorbRate + payment_scheme + process_by + sub_merchant_list; var newCypher = Pg2c2pEncryption.GetHmacSha256HexText(message, authSecretKey); return(hash_value.ToLower() == newCypher); }