How can i make a SHA1 hash in C++?

I've been googling this for hours. I need to make a SHA1 hash of a string. Please note that i need to use this SHA1 hash in a C++ windows form application which uses the .net framework. Any ideas would be greatly appreciated.
bump
bump
bump
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <msclr\auto_handle.h>

int main( array< System::String^ >^ args )
{
    System::String^ str = "hello world!" ;
    typedef msclr::auto_handle< array<unsigned char> > disposable ; 
    disposable bytes = System::Text::Encoding::UTF8->GetBytes(str) ;

    using System::Security::Cryptography::SHA1 ;
    msclr::auto_handle<SHA1> sha1_algorithm = SHA1::Create() ;
    disposable hash = sha1_algorithm->ComputeHash( bytes.get() ) ;
    const auto hash_bytes = hash.get() ;

    for( int i = 0 ; i < hash->Length ; ++i )
        System::Console::Write( hash_bytes[i].ToString("x2") ) ;
    System::Console::WriteLine() ;

    System::Console::ReadLine() ;
}
Topic archived. No new replies allowed.