/* * Returns true if the specified string is a Palindrome. */ bool isPalindrome( STR str ) { str.erase( std::remove_if( str.begin(), str.end(), ::isspace ), str.end() ); STR copy = str; std::reverse( copy.begin(), copy.end() ); return ( strcmp( str.c_str(), copy.c_str() ) == 0 ); }
void operator () (char ch) { str_ += ch; if(str_.size() >= str_.capacity()) { term_(str_.c_str(), str_.size()); str_.clear(); } }
bool FileExists(STR fn){ FILE *F = fopen(fn.c_str(), "r"); if(F){ fclose(F); return true; } return false; }
STR CCrypt::md5(STR value){ MD5_CTX ctx; unsigned char buff[MD5_DIGEST_LENGTH]; MD5_Init(&ctx); MD5_Update(&ctx, value.c_str(), value.length()); MD5_Final(buff, &ctx); char res[33]; for(int i = 0; i < 16; i++){ sprintf(res+i*2, "%02x", buff[i]); } return STR(res); }
void flush() { if(str_.size() > 0) { term_(str_.c_str(), str_.size()); str_.clear(); } }
void clear() { if(str_.size() > 0) { term_(str_.c_str(), str_.size()); } str_.clear(); }