-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from hyperwallet/DEV-v3
Dev v3
- Loading branch information
Showing
9 changed files
with
102 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
ChangeLog | ||
========= | ||
1.6.1 | ||
------------------- | ||
Added custom headers | ||
|
||
1.6.0 | ||
------------------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
namespace Hyperwallet\Util; | ||
use GuzzleHttp\Client; | ||
use GuzzleHttp\Exception\BadResponseException; | ||
use GuzzleHttp\Exception\ConnectException; | ||
use GuzzleHttp\UriTemplate; | ||
use Hyperwallet\Exception\HyperwalletApiException; | ||
use Hyperwallet\Exception\HyperwalletException; | ||
use Hyperwallet\Model\BaseModel; | ||
use Hyperwallet\Response\ErrorResponse; | ||
use Composer\Autoload\ClassLoader; | ||
use phpseclib\Crypt\RSA; | ||
use phpseclib\Math\BigInteger; | ||
use phpseclib\Crypt\Hash; | ||
use JOSE_URLSafeBase64; | ||
use JOSE_JWS; | ||
use JOSE_JWE; | ||
use JOSE_JWK; | ||
use JOSE_JWT; | ||
|
||
/** | ||
* The encryption service for Hyperwallet client's requests/responses | ||
* | ||
* @package Hyperwallet\Util | ||
*/ | ||
class HyperwalletUUID { | ||
|
||
/** | ||
* Generates UUID | ||
* | ||
* @return string | ||
* | ||
* @throws HyperwalletException | ||
*/ | ||
public static function v4() { | ||
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', | ||
|
||
// 32 bits for "time_low" | ||
mt_rand(0, 0xffff), mt_rand(0, 0xffff), | ||
|
||
// 16 bits for "time_mid" | ||
mt_rand(0, 0xffff), | ||
|
||
// 16 bits for "time_hi_and_version", | ||
// four most significant bits holds version number 4 | ||
mt_rand(0, 0x0fff) | 0x4000, | ||
|
||
// 16 bits, 8 bits for "clk_seq_hi_res", | ||
// 8 bits for "clk_seq_low", | ||
// two most significant bits holds zero and one for variant DCE1.1 | ||
mt_rand(0, 0x3fff) | 0x8000, | ||
|
||
// 48 bits for "node" | ||
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
namespace Hyperwallet\Tests\Util; | ||
|
||
use Hyperwallet\Exception\HyperwalletException; | ||
use Hyperwallet\Util\HyperwalletUUID; | ||
|
||
class HyperwalletUUIDTest extends \PHPUnit_Framework_TestCase { | ||
|
||
public function testShouldSuccessfullyGenerateRandomUUIDs() { | ||
// Setup data | ||
$UUIDUtility = new HyperwalletUUID(); | ||
|
||
// Execute test | ||
$uuid1 = $UUIDUtility->v4(); | ||
$uuid2 = $UUIDUtility->v4(); | ||
$uuid3 = $UUIDUtility->v4(); | ||
|
||
// Validate result | ||
$this->assertNotEquals($uuid1, $uuid2); | ||
$this->assertNotEquals($uuid2, $uuid3); | ||
$this->assertNotEquals($uuid3, $uuid1); | ||
} | ||
} |