From 92d73c497c403a0f0c58c8fe19d36200a3ffb154 Mon Sep 17 00:00:00 2001 From: TheDcoder Date: Fri, 23 Jun 2017 08:37:06 +0530 Subject: [PATCH 1/3] Add support for numbers in makeStandardSymbol Dealing with crypto currencies with numericals in their symbol is now possible --- exchange.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exchange.php b/exchange.php index 9f84793..34e5321 100644 --- a/exchange.php +++ b/exchange.php @@ -58,7 +58,7 @@ public function getSymbols() { // note: $exchangeSymbol must be have the base currency first and quote currency second (i.e. eth_btc Not btc_eth). The quote currency is usually BTC, USD, or CNY. public function makeStandardSymbol($exchangeSymbol) { // Convert to Uppercase and remove nonletters. - return preg_replace('/[^A-Z]/', '', strtoupper ( $exchangeSymbol )); + return preg_replace('/[^A-Z0-9]/', '', strtoupper ( $exchangeSymbol )); } // @todo not implemented for all exchanges, setSymbols() must create associative array $this->symbols with keys as standard symbols and values as exchange symbols for this function to work. public function getExchangeSymbol($standardSymbol) { From db02f8213ceebfcc09f1825cdcfffc61f51dc91c Mon Sep 17 00:00:00 2001 From: TheDcoder Date: Sat, 1 Jul 2017 10:41:52 +0530 Subject: [PATCH 2/3] Update makeStandardSymbol Literally return the `$exchangeSymbol` --- exchange.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exchange.php b/exchange.php index 34e5321..b2df4b3 100644 --- a/exchange.php +++ b/exchange.php @@ -58,7 +58,7 @@ public function getSymbols() { // note: $exchangeSymbol must be have the base currency first and quote currency second (i.e. eth_btc Not btc_eth). The quote currency is usually BTC, USD, or CNY. public function makeStandardSymbol($exchangeSymbol) { // Convert to Uppercase and remove nonletters. - return preg_replace('/[^A-Z0-9]/', '', strtoupper ( $exchangeSymbol )); + return $exchangeSymbol; } // @todo not implemented for all exchanges, setSymbols() must create associative array $this->symbols with keys as standard symbols and values as exchange symbols for this function to work. public function getExchangeSymbol($standardSymbol) { From 4be9403181b04ba0e1f3ad12ec28e9987e296c48 Mon Sep 17 00:00:00 2001 From: TheDcoder Date: Sat, 1 Jul 2017 10:48:59 +0530 Subject: [PATCH 3/3] Use random_bytes for $nonce --- cryptopiaAPI.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cryptopiaAPI.php b/cryptopiaAPI.php index f00aecb..d25c939 100644 --- a/cryptopiaAPI.php +++ b/cryptopiaAPI.php @@ -36,7 +36,7 @@ private function apiCall($method, array $req = array()) { curl_setopt($ch, CURLOPT_URL, $url ); } elseif ( in_array( $method, $private_set ) ) { $url = "https://www.cryptopia.co.nz/Api/" . $method; - $nonce = explode(' ', microtime())[1]; + $nonce = base64_encode(random_bytes(128)); $post_data = json_encode( $req ); $m = md5( $post_data, true ); $requestContentBase64String = base64_encode( $m );