Skip to content

Commit

Permalink
Move literals to a separate namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico8340 committed Feb 18, 2024
1 parent ebb88ef commit 484a0ef
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Shared/sdk/SharedUtil.Crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
#include <cryptopp/md5.h>
#include "SString.h"

namespace
{
const SString baseURLVariant = "URL";
const SString baseHexVariant = "HEX";
}

namespace SharedUtil
{
struct KeyPair
Expand All @@ -30,7 +36,7 @@ namespace SharedUtil
{
SString result;

if (variant == "URL")
if (variant == baseURLVariant)
{
CryptoPP::StringSource ss(data, true, new CryptoPP::Base64URLEncoder(new CryptoPP::StringSink(result), false));
}
Expand All @@ -46,7 +52,7 @@ namespace SharedUtil
{
SString result;

if (variant == "URL")
if (variant == baseURLVariant)
{
CryptoPP::StringSource ss(data, true, new CryptoPP::Base64URLDecoder(new CryptoPP::StringSink(result)));
}
Expand All @@ -62,7 +68,7 @@ namespace SharedUtil
{
SString result;

if (variant == "HEX")
if (variant == baseHexVariant)
{
CryptoPP::StringSource ss(data, true, new CryptoPP::Base32HexEncoder(new CryptoPP::StringSink(result), false));
}
Expand All @@ -78,7 +84,7 @@ namespace SharedUtil
{
SString result;

if (variant == "HEX")
if (variant == baseHexVariant)
{
CryptoPP::StringSource ss(data, true, new CryptoPP::Base32HexDecoder(new CryptoPP::StringSink(result)));
}
Expand Down

0 comments on commit 484a0ef

Please sign in to comment.