Hi
I have a problem
I'm trying to hash a string "abc" with function RIPEMD160, but my
hash_value is not correct
My code is:

string s=”abc”;

int a = (s.size()+1)%64;
int b = 56-a+((a>56)?64:0); PADDING
int tot = a+b+8;

char * testo=new char [tot];

for(int j=0; j<a-1; j++)
        testo[j]=s.c_str()[j];
for(int j=a-1; j<tot; j++)
        testo[j]=0;

cout<<"adding bits 1000 0000"<<endl;
testo[a-1]= 128; //byte 10000000
unsigned long long sl = s.size()*8;
        testo[a+b]   = (sl     & 0xFF);  //Unicode little-endian
        testo[a+b+1] = (sl>>8  & 0xFF);
        testo[a+b+2] = (sl>>16 & 0xFF);
        testo[a+b+3] = (sl>>24 & 0xFF);
        testo[a+b+4] = (sl>>32 & 0xFF);
        testo[a+b+5] = (sl>>40 & 0xFF);
        testo[a+b+6] = (sl>>48 & 0xFF);
        testo[a+b+7] = (sl>>56 & 0xFF);


        RIPEMD160 hash;

word32 *digest= new word32 [5];

hash.InitState(digest);

        for(int j=0; j<tot; j+=64)
{
hash.Transform(digest,(const word32 *)(&(testo[j])));
        }

        cout<<"The hash value is: "<<endl;
        for(int j=0; j<5; j++)
                cout<<std::hex<<digest[j];
        cout<<endl;

Where is the problem?
Please help me,this is a project for an university exam
Thanks a lot

-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.

Reply via email to