$did1, 'password' => $pass_word); $return = $client->call('ping', $args); echo $return; } else { $url = $hostport . $baseurl; $client = new nusoap_client($url); $INFILE; $OUTFILE; $number = 0; $iterations = 1; $encrypt = false; $decrypt = false; $both = false; $delete = false; $search = false; $batchSearch = false; $batchDelete = false; $batchEncrypt = false; $batchDecrypt = false; $USAGE = "Usage: php Program.php https:// E <# of iterations> php Program.php https:// D php Program.php https:// B <# of iterations> php Program.php https:// L php Program.php https:// S <16-digit-PAN> php Program.php https:// BE php Program.php https:// BD php Program.php https:// BL php Program.php https:// BS php Program.php P https:// " . PHP_EOL; $did = $argv[2]; $username = $argv[3]; $password = $argv[4]; $operation = $argv[5]; if (sizeof($argv) < 7) { echo $USAGE; } else { //encrypt operation if (strcasecmp($operation, E) == 0) { $number = $argv[6]; $iterations = $argv[7]; $encrypt = true; } //both operation if (strcasecmp($operation, B) == 0) { $number = $argv[6]; $iterations = $argv[7]; $both = true; } //decrypt operation if (strcasecmp($operation, D) == 0) { $token = $argv[6]; $decrypt = true; } //search operation if (strcasecmp($operation, S) == 0) { $number = $argv[6]; $search = true; } //delete operation if (strcasecmp($operation, L) == 0) { $token = $argv[6]; $delete = true; } //BatchEncrypt operation if (strcasecmp($operation, BE) == 0) { $INFILE = $argv[6]; $batchEncrypt = true; } //BatchDecrypt operation if (strcasecmp($operation, BD) == 0) { $INFILE = $argv[6]; $batchDecrypt = true; } //BatchSearch operation if (strcasecmp($operation, BS) == 0) { $INFILE = $argv[6]; $batchSearch = true; } //BatchDelete operation if (strcasecmp($operation, BL) == 0) { $INFILE = $argv[6]; $batchDelete = true; } //Start of the Encrypt operation if ($encrypt == true) { if (sizeof($argv) < 8) { echo $USAGE; } else { echo "Calling Encryption Service at " . $argv[1] . PHP_EOL; for ($i = 1; $i <= $iterations; $i++) { $args = array('did' => $did, 'username' => $username, 'password' => $password, 'plaintext' => $number); //Encrypt the number $return = $client->call('encrypt', $args); if ($client->faultcode == "S:Server") { echo $client->faultstring . PHP_EOL; } else { echo PHP_EOL . "Original Value: " . $number; echo " Token Number: " . $return . PHP_EOL; } $number++; } } } //Start of both Encrypt and Decrypt operation else if ($both == true) { echo "Calling Encryption and Decryption service at " . $argv[1] . PHP_EOL; for ($i = 1; $i <= $iterations; $i++) { $args = array('did' => $did, 'username' => $username, 'password' => $password, 'plaintext' => $number); //Encrypt the number $encrypt_return = $client->call('encrypt', $args); if ($client->faultcode == "S:Server") { echo $client->faultstring . PHP_EOL; } $args = array('did' => $did, 'username' => $username, 'password' => $password, 'token' => $encrypt_return); //Now Decrypt and verify $return = $client->call('decrypt', $args); if ($return == $number) { echo PHP_EOL . "Original Value: " . $number; echo " Token Number: " . $encrypt_return . PHP_EOL; echo "SUCCESS: Original and recovered PANs are identical!" . PHP_EOL; } else if ($client->faultcode == "S:Server") { echo $client->faultstring . PHP_EOL; } $number++; } } //Start of the Decrypt operation else if ($decrypt == true) { echo "Calling Decryption service at " . $argv[1] . PHP_EOL; $args = array('did' => $did, 'username' => $username, 'password' => $password, 'token' => $token); //Decrypt and verify $return = $client->call('decrypt', $args); if ($client->faultcode == "S:Server") echo $client->faultstring . PHP_EOL; else echo "Success: Recovered token " . $return . PHP_EOL; } //Start of the Delete operation else if ($delete == true) { echo "Calling Deletion service at......" . $argv[1] . PHP_EOL; $args = array('did' => $did, 'username' => $username, 'password' => $password, 'token' => $token); //delete should return boolean.True if successful $return = $client->call('delete', $args); echo "SUCCESS: Deleted number: " . $token . PHP_EOL; } //Start of the Search operation else if ($search == true) { echo "Calling Search service at......" . $argv[1] . PHP_EOL; $args = array('did' => $did, 'username' => $username, 'password' => $password, 'plaintext' => $number); //Search for the number $return = $client->call('search', $args); if ($return == NULL) { echo "Original Value: " . $number; echo ". Number does not exist" . PHP_EOL; } else { if ($client->faultcode == "S:Server") { echo $client->faultstring . PHP_EOL; } else { echo "Original Value: " . $number; echo " Number exists as TOken: " . $return . PHP_EOL; } } } //Start of the Batch Encrypt operation else if (batchEncrypt) { echo "Calling BatchEncrypt service at " . $argv[1] . PHP_EOL; $args = array('did' => $did, 'username' => $username, 'password' => $password, 'inputfile' => $INFILE); //submit the batch job $return = $client->call('batchEncrypt', $args); if ($client->faultcode == "S:Server") echo $client->faultstring . PHP_EOL; else echo $return; } //Start of the BatchDecrypt operation else if (batchDecrypt) { echo "Calling BatchDecrypt service at " . $argv[1]; $args = array('did' => $did, 'username' => $username, 'password' => $password, 'inputfile' => $INFILE); //submit the batch job $return = $client->call('batchDecrypt', $args); if ($client->faultcode == "S:Server") echo $client->faultstring . PHP_EOL; else echo $return; } //Start of the BatchSearch operation else if (batchSearch) { echo "Calling BatchSearch service at " . $argv[1]; $args = array('did' => $did, 'username' => $username, 'password' => $password, 'inputfile' => $INFILE); //submit the batch job $return = $client->call('batchSearch', $args); if ($client->faultcode == "S:Server") echo $client->faultstring . PHP_EOL; else echo $return; } //Start of the BatchDelete operation else if (batchDelete) { echo "Calling BatchDelete service at " . $argv[1]; $args = array('did' => $did, 'username' => $username, 'password' => $password, 'inputfile' => $INFILE); //submit the batch job $return = $client->call('batchDelete', $args); if ($client->faultcode == "S:Server") echo $client->faultstring . PHP_EOL; else echo $return; } } } ?>