add GetSHA1ForString

This commit is contained in:
Glenn Maynard
2007-07-30 03:59:20 +00:00
parent c7da72905b
commit b5c81c7d7b
2 changed files with 16 additions and 1 deletions
+14
View File
@@ -444,6 +444,20 @@ RString CryptManager::GetMD5ForString( RString sData )
return RString( (const char *) digest, sizeof(digest) );
}
RString CryptManager::GetSHA1ForString( RString sData )
{
unsigned char digest[16];
int iHash = register_hash( &sha1_desc );
hash_state hash;
int iRet = hash_descriptor[iHash].init( &hash );
iRet = hash_descriptor[iHash].process( &hash, (const unsigned char *) sData.data(), sData.size() );
iRet = hash_descriptor[iHash].done( &hash, digest );
return RString( (const char *) digest, sizeof(digest) );
}
RString CryptManager::GetPublicKeyFileName()
{
return PUBLIC_KEY_PATH;
+2 -1
View File
@@ -22,8 +22,9 @@ public:
static void GetRandomBytes( void *pData, int iBytes );
static RString GetMD5ForFile( RString fn ); // binary
static RString GetMD5ForFile( RString fn ); // in binary
static RString GetMD5ForString( RString sData ); // in binary
static RString GetSHA1ForString( RString sData ); // in binary
static RString GetPublicKeyFileName();
};