Developer Guide

SHA1-64K Hash Function

FraudLabs Pro uses SHA1 with 64k loops to hash the sensitive values, such as, email_hash, username_hash, password_hash and card_hash. User is required to hash these values prior to API request using the sample codes given below, otherwise the API will returns you the error.

Online Hash Generator

To confirm you have implemented the hashing correctly, you can compare the result with our hash generator.

Sample Codes

<?php function fraudlabspro_hash($s){
	$hash = 'fraudlabspro_' . $s;
	for($i=0; $i<65536; $i++) $hash = sha1('fraudlabspro_' . $hash);

	return $hash;
} ?>
import java.security.MessageDigest;
import java.util.Formatter;

public class main {
	public static String SHA1(String s) throws Exception{
		MessageDigest sha1 = MessageDigest.getInstance("SHA1");
		Formatter formatter = new Formatter();

		sha1.update(s.getBytes());

		byte[] hash = sha1.digest();

		for(byte b : hash){
			formatter.format("%02x", b);
		}

		return formatter.toString();
	}

	public static String fraudlabspro_hash(String s) throws Exception{
		Integer i = 0;
		String hash = "fraudlabspro_" + s;

		for(i=0; i<65536; i++){
			hash = SHA1("fraudlabspro_" + hash);
		}

		return hash;
	}
}
Imports System.Security.Cryptography

Public Function fraudlabspro_hash(ByVal s As String) As String
	Dim i As Integer = 0
	Dim hash As String = "fraudlabspro_" + s

	For i = 1 To 65536
		hash = Me.SHA1("fraudlabspro_" + hash)
	Next

	Return hash
End Function

Public Function SHA1(ByVal s As String) As String
	Dim sha As New SHA1CryptoServiceProvider
	Dim bytes() As Byte
	Dim x As String = ""

	bytes = System.Text.Encoding.ASCII.GetBytes(s)
	bytes = sha.ComputeHash(bytes)

	For Each b As Byte In bytes
		x += b.ToString("x2")
	Next

	Return x
End Function
using System.Security.Cryptography;

public string fraudlabspro_hash(string s)
{
	int i = 0;
	string hash = "fraudlabspro_" + s;

	for (i = 1; i <= 65536; i++) {
		hash = this.SHA1("fraudlabspro_" + hash);
	}

	return hash;
}

public string SHA1(string s)
{
	SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider();
	byte[] bytes = null;
	string x = "";

	bytes = System.Text.Encoding.ASCII.GetBytes(s);
	bytes = sha.ComputeHash(bytes);

	foreach (byte b in bytes) {
		x += b.ToString("x2");
	}

	return x;
}
import hashlib

def fraudlabspro_hash(s):
		hash = "fraudlabspro_" + s

		for i in range(65536):
				hash = hashlib.sha1("fraudlabspro_" + hash).hexdigest()

		return hash