singrdk/base/Applications/Security/CryptoBvt/CryptoBvt.cs

44 lines
1.1 KiB
C#
Raw Normal View History

2008-03-05 09:52:00 -05:00
///////////////////////////////////////////////////////////////////////////////
//
// Microsoft Research Singularity
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
using System;
using System.Collections.Generic;
using System.Text;
namespace CryptoBvt
{
class Program
{
static void Main(string[] args)
{
MD4Test.VerifyKnownDigests();
DesTest.RunTests();
}
}
class Util
{
public const string HexDigits = "0123456789abcdef";
public static string! ByteArrayToString(byte[]! buffer, int index, int length)
{
StringBuilder sb = new StringBuilder(length * 2);
2008-11-17 18:29:00 -05:00
for (int i = 0; i < length; i++) {
2008-03-05 09:52:00 -05:00
byte b = buffer[index + i];
sb.Append(HexDigits[b >> 4]);
sb.Append(HexDigits[b & 0xf]);
}
return sb.ToString();
}
public static string! ByteArrayToStringHex(byte[]! buffer)
{
return ByteArrayToString(buffer, 0, buffer.Length);
}
}
}