From 170d2b186b45ce0d22be4517c44362dd41d4d75c Mon Sep 17 00:00:00 2001 From: David Kelly Date: Mon, 14 Aug 2017 13:48:09 -0700 Subject: [PATCH] url encode the base64 signature/key --- interface/src/commerce/Wallet.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/interface/src/commerce/Wallet.cpp b/interface/src/commerce/Wallet.cpp index c7ebc9c96f..dd1a463237 100644 --- a/interface/src/commerce/Wallet.cpp +++ b/interface/src/commerce/Wallet.cpp @@ -207,7 +207,7 @@ bool Wallet::createIfNeeded() { qCDebug(commerce) << "read private key"; RSA_free(key); // K -- add the public key since we have a legit private key associated with it - _publicKeys.push_back(publicKey.toBase64()); + _publicKeys.push_back(QUrl::toPercentEncoding(publicKey.toBase64())); return false; } } @@ -219,9 +219,8 @@ bool Wallet::generateKeyPair() { qCInfo(commerce) << "Generating keypair."; auto keyPair = generateRSAKeypair(); - // TODO: do we need to pass params in here to make sure this is url-safe base64? - _publicKeys.push_back(keyPair.first->toBase64()); - qCDebug(commerce) << "public key:" << keyPair.first->toBase64(); + _publicKeys.push_back(QUrl::toPercentEncoding(keyPair.first->toBase64())); + qCDebug(commerce) << "public key:" << _publicKeys.last; // It's arguable whether we want to change the receiveAt every time, but: // 1. It's certainly needed the first time, when createIfNeeded answers true. @@ -264,7 +263,7 @@ QString Wallet::signWithKey(const QByteArray& text, const QString& key) { if (encryptReturn != -1) { // TODO: do we need to pass options in here to make sure it is url-safe? - return signature.toBase64(); + return QUrl::toPercentEncoding(signature.toBase64()); } } return QString();