using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Security.Cryptography;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
MD5 mMD5 = new MD5CryptoServiceProvider();
byte[] bHash;
byte[] bBlock = new Byte[512];
StreamWriter[] swWriters512 = CreateWriters( "table.512.fragments." );
/*Repeated for every block size*/
StreamWriter[] swWriters1 = CreateWriters( "table.1. fragments." );
int iLineCounter = 0;
Stream sFileList = File.OpenRead( args[0] );
StreamReader srFileList = new StreamReader( sFileList );
string sFileDataName = srFileList.ReadLine();
while (sFileDataName != null)
{
string sFileDataHash = sFileDataName.Substring( 6, 32 );
if (iLineCounter++ % 10 == 0 )
Console.WriteLine( "Processing {0}.", sFileDataHash);
Stream sFileData = File.OpenRead( sFileDataName );
BufferedStream bsFileData = new BufferedStream( sFileData );
int iCounter = 0;
while ( bsFileData.Read( bBlock, 0, 512) == 512 )
{
bHash = mMD5.ComputeHash( bBlock );
swWriters512[ bHash[0] ].WriteLine( "{0} {1} {2,5}", HashString( bHash ), sFileDataHash, iCounter );
/*Repeated for every block size*/
bHash = mMD5.ComputeHash( bBlock, 499, 1 );
swWriters1 [ bHash[0] ].WriteLine( "{0} {1} {2,5}", HashString( bHash ), sFileDataHash, iCounter );
iCounter++;
}
bsFileData.Close();
sFileDataName = srFileList.ReadLine();
}
srFileList.Close();
CloseWriters( swWriters1 );
/*Repeated for every block size*/
CloseWriters( swWriters512 );
}
static StreamWriter[] CreateWriters( string sFilename )
{
StreamWriter[] swWriters = new StreamWriter[256];
for( int iCounter=0; iCounter %26lt;= 255 ; iCounter++ )
{
swWriters[ iCounter ] = new StreamWriter( sFilename + iCounter.ToString( "x2" ) );
}
return swWriters;
}
static void CloseWriters( StreamWriter[] swWriters )
{
for( int iCounter=0; iCounter %26lt;= 255 ; iCounter++ )
{
swWriters[iCounter].Close();
}
}
static string HashString( byte[] hash )
{
return hash[0].ToString("x2") + hash[1].ToString("x2") + hash[2].ToString("x2") + hash[3].ToString("x2") +
hash[4].ToString("x2") +
hash[5].ToString("x2") +
hash[6].ToString("x2") +
hash[7].ToString("x2") +
hash[8].ToString("x2") +
hash[9].ToString("x2") +
hash[10].ToString("x2") +
hash[11].ToString("x2") +
hash[12].ToString("x2") +
hash[13].ToString("x2") +
hash[14].ToString("x2") +
hash[15].ToString("x2");
}
}
}
Pl explain me following c#.net program..plzz its very urgent..?
Computer Tutorials, Interview Question And Answer
http://freshbloger.com/
Reply:It lookes like its doing some encrytion.
Do some researce on the MD5CryptoServiceProvider Class
Reply:It's decrypting a file using MD5 encryption.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment