Path: blob/master/bitget-php-sdk-api/src/internal/Utils.php
518 views
<?php123namespace bitget\internal;456class Utils7{8public static function getSign($timestamp, $method, $requestPath, $body, $apiSecret): string9{10if ($body != null) {11$message = (string)$timestamp . strtoupper($method) . $requestPath . (string)$body;12} else {13$message = (string)$timestamp . strtoupper($method) . $requestPath;14}1516return base64_encode(hash_hmac('sha256', $message, $apiSecret, true));17}1819public static function getSignByRSA($timestamp, $method, $requestPath, $body, $apiSecret):string20{21$rsaUtil = new RsaUtil(null, $apiSecret);22if ($body != null) {23$message = (string)$timestamp . strtoupper($method) . $requestPath . (string)$body;24} else {25$message = (string)$timestamp . strtoupper($method) . $requestPath;26}2728// print_r("fuck rsa\n");29print_r($rsaUtil->sign($message) . "\n");30return $rsaUtil->sign($message);31}3233// 获取IOS格式时间戳34public static function getTimestamp(): int35{36return time() * 1000;37}3839public static function printLog(string $msg, string $type): void40{41$time = date("Y-m-d H:i:s");42print_r("[" . $time . "] [" . $type . "] " . $msg . "\n");43}4445}4647