Skip to content

Commit ed4d22c

Browse files
committed
modify base64 namespace
1 parent c82edb9 commit ed4d22c

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

include/tigerapi/client_config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ namespace TIGER_API {
5454
return this->server_url;
5555
}
5656

57+
utility::string_t get_server_pub_key() {
58+
return this->server_public_key;
59+
}
60+
5761
private:
5862
bool sandbox_debug = false;
5963
utility::string_t server_url = TIGER_SERVER_URL;

src/common/base64.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include <string>
4040
#include <cpprest/details/basic_types.h>
4141

42-
namespace websocketpp {
42+
namespace TIGER_API {
4343

4444
static utility::string_t base64_chars = U("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
4545

src/common/sign_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ int sha1_verify(const utility::string_t& context, const utility::string_t& sign,
8787
utility::char_t sigbuf[8196 * 16] = {};
8888
unsigned int siglen = 0;
8989

90-
utility::string_t decoded = websocketpp::base64_decode(sign);
90+
utility::string_t decoded = TIGER_API::base64_decode(sign);
9191
memcpy(sigbuf, decoded.data(), decoded.size());
9292
siglen = decoded.size();
9393

src/tiger_client.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "../include/tigerapi/contract_util.h"
55
#include "../include/common/easylogging++.h"
66

7-
using namespace websocketpp;
7+
using namespace TIGER_API;
88

99
namespace TIGER_API {
1010

@@ -116,7 +116,7 @@ namespace TIGER_API {
116116
exit(code);
117117
}
118118
utility::string_t res_sign = result[P_SIGN].as_string();
119-
bool is_sign_ok = verify_sign(SANDBOX_TIGER_PUBLIC_KEY, params[P_TIMESTAMP].as_string(), res_sign);
119+
bool is_sign_ok = verify_sign(client_config.get_server_pub_key(), params[P_TIMESTAMP].as_string(), res_sign);
120120
if (!is_sign_ok) {
121121
LOG(ERROR) << U("Exception: response sign verify failed. ");
122122
exit(-1);

src/utils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
using namespace std;
1212
using namespace web;
13-
using namespace websocketpp;
13+
using namespace TIGER_API;
1414

1515
utility::string_t convert_str(std::string s) {
1616
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
@@ -48,7 +48,7 @@ utility::string_t get_sign(utility::string_t &private_key, const utility::string
4848
utility::string_t filled_private_key = fill_private_key_marker(private_key);
4949

5050
utility::string_t encrypted = sha1_sign(content, filled_private_key);
51-
return websocketpp::base64_encode(encrypted);
51+
return TIGER_API::base64_encode(encrypted);
5252
}
5353

5454
bool verify_sign(utility::string_t public_key, const utility::string_t &content,

0 commit comments

Comments
 (0)