public static string GenerateCheckSumByJson(string masterKey, string json) { CheckSum.ValidateGenerateCheckSumInput(masterKey); try { string str = json; string randomString = StringUtils.GenerateRandomString(4); return(Crypto.Encrypt(SecurityUtils.GetHashedString(str + "|" + randomString) + randomString, masterKey)); } catch (System.Exception ex) { throw new CryptoException("Exception occurred while generating CheckSum. " + ex.Message); } }
public static string GenerateCheckSumForRefund(string masterKey, Dictionary <string, string> parameters) { CheckSum.ValidateGenerateCheckSumInput(masterKey); try { string checkSumString = SecurityUtils.CreateCheckSumString(parameters); string randomString = StringUtils.GenerateRandomString(4); string inputValue = checkSumString + randomString; MessageConsole.WriteLine(); MessageConsole.WriteLine("Final CheckSum String:::: " + inputValue); string hashedString = SecurityUtils.GetHashedString(inputValue); MessageConsole.WriteLine(); MessageConsole.WriteLine("HashedCheckSum String:::: " + hashedString); string clearText = hashedString + randomString; MessageConsole.WriteLine(); MessageConsole.WriteLine("HashedCheckSum String with Salt:::: " + clearText); return(Crypto.Encrypt(clearText, masterKey)); } catch (System.Exception ex) { throw new CryptoException("Exception occurred while generating CheckSum. " + ex.Message); } }
public static string GenerateCheckSum(string masterKey, Dictionary <string, string> parameters) { CheckSum.ValidateGenerateCheckSumInput(masterKey); Dictionary <string, string> parameters1 = new Dictionary <string, string>(); try { foreach (string key in parameters.Keys) { if (parameters[key].Trim().ToUpper().Contains("REFUND") || parameters[key].Trim().Contains("|")) { parameters1.Add(key.Trim(), ""); } else { parameters1.Add(key.Trim(), parameters[key].Trim()); } } string checkSumString = SecurityUtils.CreateCheckSumString(parameters1); string randomString = StringUtils.GenerateRandomString(4); string inputValue = checkSumString + randomString; MessageConsole.WriteLine(); MessageConsole.WriteLine("Final CheckSum String:::: " + inputValue); string hashedString = SecurityUtils.GetHashedString(inputValue); MessageConsole.WriteLine(); MessageConsole.WriteLine("HashedCheckSum String:::: " + hashedString); string clearText = hashedString + randomString; MessageConsole.WriteLine(); MessageConsole.WriteLine("HashedCheckSum String with Salt:::: " + clearText); return(Crypto.Encrypt(clearText, masterKey)); } catch (System.Exception ex) { throw new CryptoException("Exception occurred while generating CheckSum. " + ex.Message); } }