OpenAB  1.0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
SecureString.hpp
Go to the documentation of this file.
1 /*
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5  */
10 #ifndef SECURESTRING_HPP_
11 #define SECURESTRING_HPP_
12 
13 #include <string>
14 #include <vector>
15 
19 namespace OpenAB {
20 
27 {
28  public:
32  SecureString();
33 
38  SecureString(const char* str);
39 
44  SecureString(const std::string& str);
45 
49  SecureString(const SecureString& other);
50 
54  SecureString& operator= (const SecureString &other);
55 
59  virtual ~SecureString();
60 
66  char* str() const;
67 
72  void clearStr() const;
73 
77  void clear();
78 
82  bool operator== (const SecureString &other) const;
83 
84  private:
85  void generateKey(unsigned int size);
86 
87  std::vector<unsigned char> key;
88  std::vector<unsigned char> content;
89  mutable char *decoded;
90 };
91 
92 } // namespace OpenAB
93 
94 #endif // SECURESTRING_HPP_
SecureString()
Default constructor.
Definition: SecureString.cpp:18
SecureString & operator=(const SecureString &other)
Assignment operator.
Definition: SecureString.cpp:51
void clear()
Clears managed string.
Definition: SecureString.cpp:88
SecureString class, used to store strings like passwords etc. Current implementation encodes string i...
Definition: SecureString.hpp:26
void clearStr() const
Clears internal state after calling str(). To be used when string returned by str() is no longer need...
Definition: SecureString.cpp:95
virtual ~SecureString()
Destructor, virtual by default.
Definition: SecureString.cpp:110
bool operator==(const SecureString &other) const
Comparison operator.
Definition: SecureString.cpp:105
char * str() const
Returns managed string. When returned string is no longer needed, clearStr should be called...
Definition: SecureString.cpp:69