using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using System.Security.Cryptography;
public static void Main()
var content = "{\"header\":{\"requestId\":\"0387c41d-278a-4cbc-b53f-64f08ca29c2d\",\"swtId\":\"CC82C381E078482AB328943FCCB7100C\",\"returnCode\":\"00\",\"reasonCode\":\"00\",\"message\":\"Başarılı\",\"timestamp\":\"2021-01-13T09:06:10.529+0000\",\"hashedData\":\"2DFEBB764EB41DA5471D14F8102D4DF7F0894948693E68F28720D337C46E6533\"},\"orderId\":\"b3cf3c4b7f4c42a2838ea1e9fa414b28\",\"txnAmount\":565.00,\"installmentCount\":0,\"card\":{\"binNumber\":\"537829\",\"bankId\":\"\",\"maskedNumber\":\"537829******1012\",\"bankName\":\"\"},\"acquirerId\":\"62\",\"acquirerResponse\":{\"terminalId\":\"30690168\",\"merchantId\":\"7000679\",\"orderId\":\"b3cf3c4b7f4c42a2838ea1e9fa414b28\",\"orderGroupId\":\"\",\"returnCode\":\"00\",\"reasonCode\":\"00\",\"errorMessage\":\"\",\"retRefNum\":\"101302769518\",\"authCode\":\"470845\",\"provisionDate\":\"20210113 12:06:10\",\"extraData\":{\"mode\":\"\",\"terminal.provUserID\":\"PROVAUT\",\"terminal.userID\":\"PROVAUT\",\"terminal.id\":\"30690168\",\"terminal.merchantID\":\"7000679\",\"customer.ipAddress\":\"78.189.143.231\",\"customer.emailAddress\":\"\",\"order.orderID\":\"b3cf3c4b7f4c42a2838ea1e9fa414b28\",\"order.groupID\":\"\",\"transaction.response.source\":\"HOST\",\"transaction.response.code\":\"00\",\"transaction.response.reasonCode\":\"00\",\"transaction.response.message\":\"Approved\",\"transaction.response.errorMsg\":\"\",\"transaction.response.sysErrMsg\":\"\",\"transaction.retrefNum\":\"101302769518\",\"transaction.authCode\":\"470845\",\"transaction.batchNum\":\"004627\",\"transaction.sequenceNum\":\"000055\",\"transaction.provDate\":\"20210113 12:06:10\",\"transaction.cardNumberMasked\":\"537829******1012\",\"transaction.cardHolderName\":\"4505******* 4505**********\",\"transaction.cardType\":\"SF\",\"transaction.hashData\":\"7C377DD8D82D5F6DE7FA2D3E835BC90F520C370C\",\"transaction.hostMsgList.hostMsg\":\"6567 - CENGIZ SSAHIN TESTOOUUGGIISSCC\",\"transaction.rewardInqResult.rewardList.reward\":[],\"transaction.rewardInqResult.chequeList\":{},\"transaction.campaignChooseLink\":\" https://sanalposprov-t.garantibbva.com.tr/servlet/campaignchoose?campaignKey=142806F5D83A2D38A3C31C59F542BB8B0E5DA1BC\"}}}";
var jsonResult = JObject.Parse(content);
var requestId = "0387c41d-278a-4cbc-b53f-64f08ca29c2d";
var swtId = "CC82C381E078482AB328943FCCB7100C";
var message = "Başarılı";
var timestamp = "2021-01-13T09:06:10.529+0000";
Console.WriteLine(CalculateHash(requestId + swtId + returnCode + reasonCode + message + timestamp + pass));
Console.WriteLine(GetSHA1(requestId + swtId + returnCode + reasonCode + message + timestamp + pass, "hex"));
Console.WriteLine("2DFEBB764EB41DA5471D14F8102D4DF7F0894948693E68F28720D337C46E6533");
private static string CalculateHash(string rawData)
if (string.IsNullOrEmpty(rawData))
using (SHA256 sha256Hash = SHA256.Create())
byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(rawData));
return GetHexaDecimal(bytes).ToUpper();
private static string GetHexaDecimal(byte[] bytes)
StringBuilder s = new StringBuilder();
int length = bytes.Length;
for (int n = 0; n <= length - 1; n++)
s.Append(String.Format("{0,2:x}", bytes[n]).Replace(" ", "0"));
private static string GetSHA1(string SHA1Data, string format)
SHA1 sha = new SHA1CryptoServiceProvider();
string HashedPassword = SHA1Data;
byte[] hashbytes = Encoding.ASCII.GetBytes(HashedPassword);
byte[] inputbytes = sha.ComputeHash(hashbytes);
StringBuilder s = new StringBuilder();
int length = inputbytes.Length;
for (int n = 0; n <= length - 1; n++)
s.Append(String.Format("{0,2:x}", inputbytes[n]).Replace(" ", "0"));
return Convert.ToBase64String(inputbytes);