MD5
переделавал из MSDN пример с C# на C++, всё исправил. Осталась одна ошибка! Ни как не получается(
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
using namespace System::Security::Cryptography;
using namespace System::Text;
static String^ getMd5Hash(String ^input);
static bool verifyMd5Hash(String ^input, String ^hash);
static String^ getMd5Hash(String ^input)
{
MD5 ^md5Hasher = MD5::Create();
HashAlgorithm ^sha = gcnew SHA1CryptoServiceProvider;
array<Char> ^m=input->ToCharArray(); Int32 size=input->Length;
array<Byte> ^b=gcnew array<Byte>(size);
for(int i=0; i<size; i++) b=Convert::ToByte(m);
array<Byte> ^data = sha->ComputeHash(b);
StringBuilder^ sBuilder = gcnew StringBuilder;
for (int i = 0; i < data->Length; i++)
{
sBuilder->Append(data.ToString("x2"));
}
return sBuilder->ToString();
}
static bool verifyMd5Hash(String ^input, String ^hash)
{
String^ hashOfInput = getMd5Hash(input);
StringComparer ^comparer = StringComparer::OrdinalIgnoreCase;
if (0 == comparer->Compare(hashOfInput, hash))
{
return true;
}
else
{
return false;
}
}
static void Main()
{
String^ source = "Hello World!";
String^ hash = getMd5Hash(source);
Console::WriteLine("The MD5 hash of " + source + " is: " + hash + ".");
Console::WriteLine("Verifying the hash...");
if (verifyMd5Hash(source, hash))
{
Console::WriteLine("The hashes are the same.");
}
else
{
Console::WriteLine("The hashes are not same.");
}
}
Может текст ошибки приведете?
Цитата: nikitozz
Может текст ошибки приведете?
пасибо! просто что-то в тот день пересидел за компом!
Ошибка глупая [неопределена точка входа]
вместо static void Main()
нужно было написать void main()