summaryrefslogtreecommitdiffabout
path: root/lib/secret.cc
Unidiff
Diffstat (limited to 'lib/secret.cc') (more/less context) (show whitespace changes)
-rw-r--r--lib/secret.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/secret.cc b/lib/secret.cc
index d538890..3f1e39c 100644
--- a/lib/secret.cc
+++ b/lib/secret.cc
@@ -1,29 +1,29 @@
1#include <algorithm> 1#include <algorithm>
2#include <functional> 2#include <functional>
3#include <opkele/types.h> 3#include <opkele/types.h>
4#include <opkele/exception.h> 4#include <opkele/exception.h>
5#include <opkele/util.h> 5#include <opkele/util.h>
6 6
7namespace opkele { 7namespace opkele {
8 using namespace std; 8 using namespace std;
9 9
10 template<class __a1,class __a2,class __r> 10 template<class __a1,class __a2,class __r>
11 struct bitwise_xor : public binary_function<__a1,__a2,__r> { 11 struct bitwise_xor : public binary_function<__a1,__a2,__r> {
12 __r operator() (const __a1& a1,const __a2& a2) const { 12 __r operator() (const __a1& a1,const __a2& a2) const {
13 return a1^a2; 13 return (__r)(a1^a2);
14 } 14 }
15 }; 15 };
16 16
17 void secret_t::enxor_to_base64(const unsigned char *key_d,string& rv) const { 17 void secret_t::enxor_to_base64(const unsigned char *key_d,string& rv) const {
18 vector<unsigned char> tmp; 18 vector<unsigned char> tmp;
19 transform( 19 transform(
20 begin(), end(), 20 begin(), end(),
21 key_d, 21 key_d,
22 back_insert_iterator<vector<unsigned char> >(tmp), 22 back_insert_iterator<vector<unsigned char> >(tmp),
23 bitwise_xor<unsigned char,unsigned char,unsigned char>() ); 23 bitwise_xor<unsigned char,unsigned char,unsigned char>() );
24 rv = util::encode_base64(&(tmp.front()),tmp.size()); 24 rv = util::encode_base64(&(tmp.front()),tmp.size());
25 } 25 }
26 26
27 void secret_t::enxor_from_base64(const unsigned char *key_d,const string& b64) { 27 void secret_t::enxor_from_base64(const unsigned char *key_d,const string& b64) {
28 clear(); 28 clear();
29 util::decode_base64(b64,*this); 29 util::decode_base64(b64,*this);