Overview
Why checksum?
To avoid data confusion and corruptness and ascertain its integrity, an MD5 checksum value is calculated and added as a parameter to the transaction HTTP request. The checksum is unique to each transaction.
You the purpose of initial Public Payment Page online testing, use the appropriate checksum generation tool
However, for the purpose of running in full production mode, an MD5 calculator must be integrated into the your web application to allow the automatic calculation of the MD5 checksum for the creation of the HTTPS POST request. Please find below code snippets of MD5 checksum implementation in popular web development languages.
C Sharp
public static string MD5_ComputeHexaHash (string text) {
// Gets the MD5 hash for text
MD5 md5 = new MD5CryptoServiceProvider();
byte[] data = Encoding.Default.GetBytes(text);
byte[] hash = md5.ComputeHash(data);
// Transforms as hexa
string hexaHash = "";
foreach (byte b in hash) {
hexaHash += String.Format("{0:x2}", b);
}
// Returns MD5 hexa hash
return hexaHash;
Java
import java.security.MessageDigest;
public static String md5sum(byte[] convertme) {
MessageDigest md = MessageDigest.getInstance("MD5");
return new String(md.digest(convertme));
}
Perl
# Functional style use Digest::MD5 qw(md5 md5_hex md5_base64); $digest = md5($data); $digest = md5_hex($data); $digest = md5_base64($data); # OO style use Digest::MD5; $ctx = Digest::MD5->new; $ctx->add($data); $digest = $ctx->digest; $digest = $ctx->hexdigest; $digest = $ctx->b64digest;
PHP
$digest = md5($data);
$digest = hash('md5',$data);
Python
import hashlib
converted = hashlib.md5("My text").hexdigest()
TCL
package require md5 set digest [md5::md5 -hex "checksum string"] # For performing incremental digest package require md5 set tok [md5::MD5Init] md5::MD5Update $tok "Tcl " md5::MD5Update $tok "does " md5::MD5Update $tok "MD5" set digest [md5::MD5Final $tok]
