Разработка программы "Формирование и проверка контрольной суммы кластеров"
HH(ref c, d, a, b, x[k + 11], S33, 0x6d9d6122); /* 35 */
HH(ref b, c, d, a, x[k + 14], S34, 0xfde5380c); /* 36 */
HH(ref a, b, c, d, x[k + 1], S31, 0xa4beea44); /* 37 */
HH(ref d, a, b, c, x[k + 4], S32, 0x4bdecfa9); /* 38 */
HH(ref c, d, a, b, x[k + 7], S33, 0xf6bb4b60); /* 39 */
HH(ref b, c, d, a, x[k + 10], S34, 0xbebfbc70); /* 40 */
HH(ref a, b, c, d, x[k + 13], S31, 0x289b7ec6); /* 41 */
HH(ref d, a, b, c, x[k + 0], S32, 0xeaa127fa); /* 42 */
HH(ref c, d, a, b, x[k + 3], S33, 0xd4ef3085); /* 43 */
HH(ref b, c, d, a, x[k + 6], S34, 0x4881d05); /* 44 */
HH(ref a, b, c, d, x[k + 9], S31, 0xd9d4d039); /* 45 */
HH(ref d, a, b, c, x[k + 12], S32, 0xe6db99e5); /* 46 */
HH(ref c, d, a, b, x[k + 15], S33, 0x1fa27cf8); /* 47 */
HH(ref b, c, d, a, x[k + 2], S34, 0xc4ac5665); /* 48 */
/* Раунд4 */
II(ref a, b, c, d, x[k + 0], S41, 0xf4292244); /* 49 */
II(ref d, a, b, c, x[k + 7], S42, 0x432aff97); /* 50 */
II(ref c, d, a, b, x[k + 14], S43, 0xab9423a7); /* 51 */
II(ref b, c, d, a, x[k + 5], S44, 0xfc93a039); /* 52 */
II(ref a, b, c, d, x[k + 12], S41, 0x655b59c3); /* 53 */
II(ref d, a, b, c, x[k + 3], S42, 0x8f0ccc92); /* 54 */
II(ref c, d, a, b, x[k + 10], S43, 0xffeff47d); /* 55 */
II(ref b, c, d, a, x[k + 1], S44, 0x85845dd1); /* 56 */
II(ref a, b, c, d, x[k + 8], S41, 0x6fa87e4f); /* 57 */
II(ref d, a, b, c, x[k + 15], S42, 0xfe2ce6e0); /* 58 */
II(ref c, d, a, b, x[k + 6], S43, 0xa3014314); /* 59 */
II(ref b, c, d, a, x[k + 13], S44, 0x4e0811a1); /* 60 */
II(ref a, b, c, d, x[k + 4], S41, 0xf7537e82); /* 61 */
II(ref d, a, b, c, x[k + 11], S42, 0xbd3af235); /* 62 */
II(ref c, d, a, b, x[k + 2], S43, 0x2ad7d2bb); /* 63 */
II(ref b, c, d, a, x[k + 9], S44, 0xeb86d391); /* 64 */
A += a;
B += b;
C += c;
D += d;
}
return new UInt32[] { A, B, C, D };
}
private static byte[] MD5Array(byte[] input)
{
MD5_Init();
UInt32[] block = MD5_Append(input);
UInt32[] bits = MD5_Trasform(block);
// Кодирует bits (UInt32[]) в output (byte[]).
byte[] output = new byte[bits.Length * 4];
for (int i = 0, j = 0; i < bits.Length; i++, j += 4)
{
output[j] = (byte)(bits[i] & 0xff);
output[j + 1] = (byte)((bits[i] >> 8) & 0xff);
output[j + 2] = (byte)((bits[i] >> 16) & 0xff);
output[j + 3] = (byte)((bits[i] >> 24) & 0xff);
}
return output;
}
private static string ArrayToHexString(byte[] array, bool uppercase)
{
string hexString = "";
string format = "x2";
if (uppercase)
{
format = "X2";
}
foreach (byte b in array)
{
hexString += b.ToString(format);
}
return hexString;
}
private static string MD5File(string fileName)
{
FileStream fs = File.Open(fileName, FileMode.Open, FileAccess.Read);
byte[] array = new byte[fs.Length];
fs.Read(array, 0, (int)fs.Length);
byte[] digest = MD5Array(array);
fs.Close();
return ArrayToHexString(digest, false);
}
}
}
//HardDrive.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace kurs_pogulyat
{
class HardDrive
{
private string model = "";
private string type = "";
private string serialNo = "";
private string bytesPerSector = "";
private string mediaType = "";
private string partitions = "";
private string sectorsPerTrack = "";
private string signature = "";
private string size = "";
private string freespace = "";
private string status = "";
private string totalCylinders = "";
private string totalHeads = "";
private string totalSectors = "";
private string totalTracks = "";
private string tracksPerCylinder = "";
private string firmwareRevision = "";
public string Model
{
get { return model; }
set { model = value; }
}
public string Type
{
get { return type; }
set { type = value; }
}
public string SerialNo
{
get { return serialNo; }
set { serialNo = value; }
}
public string BytesPerSector
{
get { return bytesPerSector; }
set { bytesPerSector = value; }
}
public string MediaType
{
get { return mediaType; }
set { mediaType = value; }
}
public string Partitions
{
get { return partitions; }
set { partitions = value; }
}
public string SectorsPerTrack
{
get { return sectorsPerTrack; }
set { sectorsPerTrack = value; }
}
public string Signature
{
get { return signature; }
set { signature = value; }
}
public string Size
{
get { return size; }
set { size = value; }
}
public string FreeSpace
{
get { return freespace; }
set { freespace = value; }
}
public string Status
{
get { return status; }
set { status = value; }
}
public string TotalCylinders
{
get { return totalCylinders; }
set { totalCylinders = value; }
}
public string TotalHeads
{
get { return totalHeads; }
set { totalHeads = value; }
}
public string TotalSectors
{
get { return totalSectors; }
set { totalSectors = value; }
}
public string TotalTracks
{
get { return totalTracks; }
set { totalTracks = value; }
}
public string TracksPerCylinder
{
get { return tracksPerCylinder; }
set { tracksPerCylinder = value; }
}
public string FirmwareRevision
{
get { return firmwareRevision; }
set { firmwareRevision = value; }
} }
}
//Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace kurs_pogulyat
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
Размещено на