Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Commit

Permalink
Fixes #55: made functions in crypto.hpp static class member functions
Browse files Browse the repository at this point in the history
  • Loading branch information
eidheim committed Dec 7, 2016
1 parent 9cdef90 commit bc5bf31
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions crypto.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ namespace SimpleWeb {
}
#endif

namespace Crypto {
namespace Base64 {
std::string encode(const std::string &ascii) {
class Crypto {
public:
class Base64 {
public:
static std::string encode(const std::string &ascii) {
std::string base64;

BIO *bio, *b64;
Expand Down Expand Up @@ -52,7 +54,7 @@ namespace SimpleWeb {
return base64;
}

std::string decode(const std::string &base64) {
static std::string decode(const std::string &base64) {
std::string ascii;

//Resize ascii, however, the size is a up to two bytes too large.
Expand All @@ -71,9 +73,9 @@ namespace SimpleWeb {

return ascii;
}
}
};

std::string MD5(const std::string &input, size_t iterations=1) {
static std::string MD5(const std::string &input, size_t iterations=1) {
std::string hash;

hash.resize(128 / 8);
Expand All @@ -85,7 +87,7 @@ namespace SimpleWeb {
return hash;
}

std::string SHA1(const std::string &input, size_t iterations=1) {
static std::string SHA1(const std::string &input, size_t iterations=1) {
std::string hash;

hash.resize(160 / 8);
Expand All @@ -97,7 +99,7 @@ namespace SimpleWeb {
return hash;
}

std::string SHA256(const std::string &input, size_t iterations=1) {
static std::string SHA256(const std::string &input, size_t iterations=1) {
std::string hash;

hash.resize(256 / 8);
Expand All @@ -109,7 +111,7 @@ namespace SimpleWeb {
return hash;
}

std::string SHA512(const std::string &input, size_t iterations=1) {
static std::string SHA512(const std::string &input, size_t iterations=1) {
std::string hash;

hash.resize(512 / 8);
Expand All @@ -120,7 +122,7 @@ namespace SimpleWeb {

return hash;
}
}
};
}
#endif /* CRYPTO_HPP */

0 comments on commit bc5bf31

Please sign in to comment.