From 987568e31b9f8ec5ca6ff032fd7e6b7201b95e5a Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Thu, 27 Mar 2014 01:09:08 -0400 Subject: [PATCH] update apis --- include/fc/crypto/elliptic.hpp | 2 +- include/fc/string.hpp | 2 ++ src/crypto/elliptic.cpp | 2 +- src/string.cpp | 16 ++++++++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/include/fc/crypto/elliptic.hpp b/include/fc/crypto/elliptic.hpp index ac411a0..71c4d12 100644 --- a/include/fc/crypto/elliptic.hpp +++ b/include/fc/crypto/elliptic.hpp @@ -99,7 +99,7 @@ namespace fc { */ fc::sha512 get_shared_secret( const public_key& pub )const; - signature sign( const fc::sha256& digest ); + signature sign( const fc::sha256& digest )const; compact_signature sign_compact( const fc::sha256& digest )const; bool verify( const fc::sha256& digest, const signature& sig ); diff --git a/include/fc/string.hpp b/include/fc/string.hpp index df2cac8..4ba03cd 100644 --- a/include/fc/string.hpp +++ b/include/fc/string.hpp @@ -21,6 +21,8 @@ namespace fc class variant_object; fc::string format_string( const fc::string&, const variant_object& ); fc::string trim( const fc::string& ); + fc::string to_lower( const fc::string& ); + string trim_and_normalize_spaces( const string& s ); } #else diff --git a/src/crypto/elliptic.cpp b/src/crypto/elliptic.cpp index dda84f2..b68ad0d 100644 --- a/src/crypto/elliptic.cpp +++ b/src/crypto/elliptic.cpp @@ -357,7 +357,7 @@ namespace fc { namespace ecc { return self; } - signature private_key::sign( const fc::sha256& digest ) + signature private_key::sign( const fc::sha256& digest )const { unsigned int buf_len = ECDSA_size(my->_key); // fprintf( stderr, "%d %d\n", buf_len, sizeof(sha256) ); diff --git a/src/string.cpp b/src/string.cpp index d09ab2f..ea5bbab 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -104,9 +104,25 @@ namespace fc { } std::string trim( const std::string& s ) { + return boost::algorithm::trim_copy(s); + /* std::string cpy(s); boost::algorithm::trim(cpy); return cpy; + */ + } + std::string to_lower( const std::string& s ) + { + auto tmp = s; + boost::algorithm::to_lower(tmp); + return tmp; + } + string trim_and_normalize_spaces( const string& s ) + { + string result = boost::algorithm::trim_copy( s ); + while( result.find( " " ) != result.npos ) + boost::algorithm::replace_all( result, " ", " " ); + return result; } } // namespace fc