The MD4 Class.(C#)
点击次数:22 次 发布日期:2008-11-06 08:08:28 作者:源代码网
|
源代码网推荐 Copyright 2002 Blood (eaststarbuy@sina.com) 源代码网推荐 源代码网推荐 This code is ported from Norbert Hranitzky"s 源代码网推荐 (norbert.hranitzky@mchp.siemens.de) 源代码网推荐 Java version. 源代码网推荐 */ 源代码网推荐 源代码网推荐 //reference Namespace 源代码网推荐 using System; 源代码网推荐 using System.Text; 源代码网推荐 源代码网推荐 namespace Blood.COM.Security 源代码网推荐 { 源代码网推荐 源代码网推荐 /// <summary> 源代码网推荐 /// Implements the MD4 message digest algorithm in C# 源代码网推荐 /// </summary> 源代码网推荐 public class MD4 源代码网推荐 { 源代码网推荐 源代码网推荐 // MD4 specific object variables 源代码网推荐 //----------------------------------------------------------------------- 源代码网推荐 源代码网推荐 /// <summary> 源代码网推荐 /// The size in bytes of the input block to the transformation algorithm 源代码网推荐 /// </summary> 源代码网推荐 private const int BLOCK_LENGTH = 64; // = 512 / 8 源代码网推荐 源代码网推荐 /// <summary> 源代码网推荐 /// 4 32-bit words (interim result) 源代码网推荐 /// </summary> 源代码网推荐 private uint[] context = new uint[4]; 源代码网推荐 源代码网推荐 /// <summary> 源代码网推荐 /// Number of bytes procesed so far mod. 2 power of 64. 源代码网推荐 /// </summary> 源代码网推荐 private long count; 源代码网推荐 源代码网推荐 /// <summary> 源代码网推荐 /// 512-bit input buffer = 16 x 32-bit words holds until it reaches 512 bits 源代码网推荐 /// </summary> 源代码网推荐 private byte[] buffer = new byte[BLOCK_LENGTH]; 源代码网推荐 源代码网推荐 /// <summary> 源代码网推荐 /// 512-bit work buffer = 16 x 32-bit words 源代码网推荐 /// </summary> 源代码网推荐 private uint[] X = new uint[16]; 源代码网推荐 源代码网推荐 源代码网推荐 // Constructors 源代码网推荐 //------------------------------------------------------------------------ 源代码网推荐 源代码网推荐 public MD4() 源代码网推荐 { 源代码网推荐 engineReset(); 源代码网推荐 } 源代码网推荐 源代码网推荐 /// <summary> 源代码网推荐 /// This constructor is here to implement the clonability of this class 源代码网推荐 /// </summary> 源代码网推荐 /// <param name="md"> </param> 源代码网推荐 private MD4(MD4 md): this() 源代码网推荐 { 源代码网推荐 //this(); 源代码网推荐 context = (uint[])md.context.Clone(); 源代码网推荐 buffer = (byte[])md.buffer.Clone(); 源代码网推荐 count = md.count; 源代码网推荐 } 源代码网推荐 源代码网推荐 // Clonable method implementation 源代码网推荐 //------------------------------------------------------------------------- 源代码网推荐 public object Clone() 源代码网推荐 { 源代码网推荐 return new MD4(this); 源代码网推荐 } 源代码网推荐 源代码网推荐 // JCE methods 源代码网推荐 //------------------------------------------------------------------------- 源代码网推荐 源代码网推荐 /// <summary> 源代码网推荐 /// Resets this object disregarding any temporary data present at the 源代码网推荐 /// time of the invocation of this call. 源代码网推荐 /// </summary> 源代码网推荐 private void engineReset() 源代码网推荐 { 源代码网推荐 // initial values of MD4 i.e. A, B, C, D 源代码网推荐 源代码网供稿. |
