author | Michael Krelin <hacker@klever.net> | 2007-01-12 12:58:25 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-01-12 12:58:25 (UTC) |
commit | e79687a3d9a1631613de02d8e12bae36302b46ab (patch) (side-by-side diff) | |
tree | 4238c0d8d61f5e70ed1e98debb01315babb21686 /lib/secret.cc | |
parent | 4cc2e58186e8cd9b96a3573c92f6664064cf11fe (diff) | |
download | libopkele-e79687a3d9a1631613de02d8e12bae36302b46ab.zip libopkele-e79687a3d9a1631613de02d8e12bae36302b46ab.tar.gz libopkele-e79687a3d9a1631613de02d8e12bae36302b46ab.tar.bz2 |
eliminated mimetic dependency and made use of openssl base64 encoder instead
-rw-r--r-- | lib/secret.cc | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/lib/secret.cc b/lib/secret.cc index ae8a3c5..632a2ca 100644 --- a/lib/secret.cc +++ b/lib/secret.cc @@ -1,61 +1,49 @@ #include <algorithm> #include <functional> #include <opkele/types.h> #include <opkele/exception.h> -#include <mimetic/mimetic.h> +#include <opkele/util.h> namespace opkele { using namespace std; template<class __a1,class __a2,class __r> struct bitwise_xor : public binary_function<__a1,__a2,__r> { __r operator() (const __a1& a1,const __a2& a2) const { return a1^a2; } }; void secret_t::enxor_to_base64(const unsigned char *key_sha1,string& rv) const { if(size()!=20) throw bad_input(OPKELE_CP_ "wrong secret size"); vector<unsigned char> tmp; transform( begin(), end(), key_sha1, back_insert_iterator<vector<unsigned char> >(tmp), bitwise_xor<unsigned char,unsigned char,unsigned char>() ); - mimetic::Base64::Encoder b(0); - mimetic::encode( - tmp.begin(),tmp.end(), b, - back_insert_iterator<string>(rv) ); + rv = util::encode_base64(&(tmp.front()),tmp.size()); } void secret_t::enxor_from_base64(const unsigned char *key_sha1,const string& b64) { - mimetic::Base64::Decoder b; clear(); - mimetic::decode( - b64.begin(),b64.end(), b, - back_insert_iterator<secret_t>(*this) ); + util::decode_base64(b64,*this); transform( begin(), end(), key_sha1, begin(), bitwise_xor<unsigned char,unsigned char,unsigned char>() ); } void secret_t::to_base64(string& rv) const { if(size()!=20) throw bad_input(OPKELE_CP_ "wrong secret size"); - mimetic::Base64::Encoder b(0); - mimetic::encode( - begin(),end(), b, - back_insert_iterator<string>(rv) ); + rv = util::encode_base64(&(front()),size()); } void secret_t::from_base64(const string& b64) { - mimetic::Base64::Decoder b; - mimetic::decode( - b64.begin(),b64.end(), b, - back_insert_iterator<secret_t>(*this) ); + util::decode_base64(b64,*this); } } |