keycodes. boost stil can't handle dates

This commit is contained in:
Kevin Darby committed 2019-05-30 18:24:24 -04:00
1 parent 7d75d87e6b
commit 8a965d41ff
24 files changed
+747 -132

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
#include "KeyCodeHelper.h"
#include "lib/utils/datetime.h"
#include "lib/utils/crypto/CryptoInit.h"
#include "lib/utils/crypto/PrivateKey.h"
#include "lib/utils/crypto/PublicKey.h"
#include "lib/config/protos/keycode.pb.h"
#include <google/protobuf/text_format.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <sstream>
#include <string>
namespace bts {
namespace crypto {
bool decrypt_keycode(const bts::crypto::PublicKey& public_key, const bts::config::EncryptedKeyCode& kc,
bts::config::KeyCode* dk)
{
std::stringstream kss, out;
kss << kc.keycode();
if(public_key.decrypt(kss, out))
{
bts::config::KeyCode kc;
google::protobuf::io::IstreamInputStream kc_stream(&kss);
google::protobuf::TextFormat::Parse(&kc_stream, &kc);
if(dk)
{
*dk = kc;
return true;
}
}
return false;
}
}}