Справочник функций

Ваш аккаунт

Войти через: 
Забыли пароль?
Регистрация
Информацию о новых материалах можно получать и без регистрации:

Почтовая рассылка

Подписчиков: -1
Последний выпуск: 19.06.2015

MD5

36K
17 декабря 2009 года
twi5ter
37 / / 06.08.2009
подскажите кто-нибудь!
переделавал из 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.");
}
}
288
18 декабря 2009 года
nikitozz
1.2K / / 09.03.2007
Может текст ошибки приведете?
36K
19 декабря 2009 года
twi5ter
37 / / 06.08.2009
Цитата: nikitozz
Может текст ошибки приведете?


пасибо! просто что-то в тот день пересидел за компом!
Ошибка глупая [неопределена точка входа]
вместо static void Main()
нужно было написать void main()

Реклама на сайте | Обмен ссылками | Ссылки | Экспорт (RSS) | Контакты
Добавить статью | Добавить исходник | Добавить хостинг-провайдера | Добавить сайт в каталог