after generation encrypt the token with SHA1 with RSA using Asp.net C#
private key:"65e365bd06f7f54a5282a63278bb21c2";
json string:{\"UserID\":\"1\",\"UserName\":\"Ayyappa\",\"txnId\":\"123456\",\"customerMob\":\"8569896857\",\"lname\":\"lakshman\",\"name\":\"Balasubbiramani\",\"mname\":\"ram\",\"productCode\":\"DMT\",\"address\":\"Mumbai\",\"dateOfBirth\":\"05/10/1982\",\"agentId\":\"CUSTOMER123456\",\"partnerId\":\"761\",\"kycStatus\":\"0\",\"pancardStatus\":\"0\",\"identityDocType\":\"0\",\"identityDocNo\":\"BgQkkDr14...\",\"channel\":\"4\",\"isOTPValidated\":\"0\",\"hashKey\":\"9f3f9eb0451e8c2e3955551c57458072\"}";

Rajkiran SwainPosted May 17, 2023, 11:03 AM
Make sure that the cryptographic provider you are using is compatible with the version of .NET Framework you are targeting. You can check the documentation for the provider to see which versions of .NET it supports.
Check that you have installed any necessary updates or patches for the .NET Framework.
Make sure that the private key you are passing is valid and that the JSON string you are using is well-formed.
If you are using a third-party cryptographic library, make sure that you have correctly installed and configured it.
If none of these solutions work, you may need to provide more information about the specific cryptographic provider you are using and the code you are using to generate the token.
Nagaveni KatariPosted May 19, 2023, 9:10 AM
string privateKey = "65e365bd06f7f54a5282a63278bb21c2";
string jsonData = {\"UserID\":\"1\",\"UserName\":\"Ayyappa\",\"txnId\":\"123456\",\"customerMob\":\"8569896857\",\"lname\":\"lakshman\",\"name\":\"Balasubbiramani\",\"mname\":\"ram\",\"productCode\":\"DMT\",\"address\":\"Mumbai\",\"dateOfBirth\":\"05/10/1982\",\"agentId\":\"CUSTOMER123456\",\"partnerId\":\"761\",\"kycStatus\":\"0\",\"pancardStatus\":\"0\",\"identityDocType\":\"0\",\"identityDocNo\":\"BgQkkDr14...\",\"channel\":\"4\",\"isOTPValidated\":\"0\",\"hashKey\":\"b2b7e6c8f6f011e2b6396c4d36d4ecd6\"}";
public string SignedToken(string privateKey, string data)
{
byte[] privateKeyBytes = HexStringToByteArrays(privateKey);
using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
{
RSAParameters privateKeyParams = rsa.ExportParameters(true);
privateKeyParams.D = privateKeyBytes;
rsa.ImportParameters(privateKeyParams);
byte[] dataBytes = Encoding.UTF8.GetBytes(data);
byte[] signatureBytes = rsa.SignData(dataBytes, HashAlgorithmName.SHA1, RSASignaturePadding.Pkcs1);
string signedString = Convert.ToBase64String(signatureBytes);
return signedString;
}
}
private byte[] HexStringToByteArrays(string hex)
{
int length = hex.Length;
byte[] bytes = new byte[length / 2];
for (int i = 0; i < length; i += 2)
{
bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
}
return bytes;
}
This is my code
Nagaveni KatariPosted May 19, 2023, 9:07 AM
Nagaveni KatariPosted May 17, 2023, 9:04 AM
Rajkiran SwainPosted May 17, 2023, 4:55 AM