Hash
HOW TO HASH USING SHA256

Step 1

1
String stringToHash = amount=100&callbackUrl=https://checkout.seerbit.com/?m=EQREZEhyRn&country=NG&currency=NGN&email=[email protected].com&paymentReference=5fgj77treo&productDescription=RiceandBeans&productId=Foods&publicKey=EQREZEhyR
Copied!

Step 2

1
String hashString = stringToHash + privateKey;
Copied!

Step 3

1
Hash = Sha256(hashString);
Copied!

Hash Algorithm in Java

1
public static String Sha256(String rawKey) throws ProcessingException {
2
try {
3
MessageDigest md = MessageDigest.getInstance("SHA-256");
4
byte[] encrypted = md.digest(rawKey.getBytes());
5
return new String(Hex.encodeHex(encrypted));
6
} catch (NoSuchAlgorithmException ex) {
7
String errorMessage = "Unable to hash this string";
8
throw new ProcessingException(errorMessage);
9
}
10
}
Copied!
Last modified 2yr ago