Skip to content

Instantly share code, notes, and snippets.

@wrilben
Last active December 21, 2017 10:14
Show Gist options
  • Save wrilben/4378ed1df7dec99bf7e08743137b05bb to your computer and use it in GitHub Desktop.
Save wrilben/4378ed1df7dec99bf7e08743137b05bb to your computer and use it in GitHub Desktop.
Generate Random Transaction Ids for your projects
<?php
##Author Benedict Asamoah
function generateTransactionID ($data){
## Get passed card information to string
$string = $data;
## Create an array
$store = array();
## create a loop that runs four times
for ($x = 0; $x <= 4; $x++) {
## Get random positions each time the loop is runned
$pos = rand(0,(strlen($string)-$x));
## Push the value and position of value to the array
array_push($store,$pos,$string[$pos]);
}
## Convert the array to a normal string
$get_strings = implode(" ",$store);
## Hash the normal string and pass it to transaction id
$transaction_id = sha1(md5($get_strings)).'k32duem01vZsQ2lB8g0s';
## Return Transaction ID
return $transaction_id.'<br/>'.$get_strings;
}
echo generateTransactionID('08967544634543');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment