OSDN Git Service

#xxxxx DTXViewerのプロジェクトを追加。
[dtxmania/dtxmania.git] / DTXViewerプロジェクト / @FDK10プロジェクト / MD5.h
1
2 /*
3  * MD5 - MD5\95\8e\9a\97ñ\82Ì\8dì\90¬
4  *
5  *\81y\8aT\97v\81z
6  *  \94C\88Ó\82Ì\83\81\83b\83Z\81[\83W\81i\83o\83C\83i\83\8a\89Â\81j\82ÌMD5\95\8e\9a\97ñ\81i16\90i\90\9432\95\8e\9a\81j\82ð\8dì\90¬\82·\82é\81B
7  *  \82½\82¾\82µ\81A\96{\83R\81[\83h\82Å\82Í\81i\8eè\82ð\94²\82¢\82Ä\82¢\82é\82Ì\82Å\81j\83\81\83b\83Z\81[\83W\82Í\8dÅ\91å 2^32 \83o\83C\83g
8  *  \82Ü\82Å\82µ\82©\91Î\89\9e\82µ\82Ä\82¢\82È\82¢\81B
9  *
10  *\81y\8eg\82¢\95û\81z
11  *  (2) MD5::Init() \82ð\8cÄ\82Ñ\8fo\82·\81B
12  *  (3) \89½\89ñ\82©\82É\82í\82¯\82Ä MD5::Update() \82ð\8cÄ\82Ñ\8fo\82µ\81A\83\81\83b\83Z\81[\83W\82ð\82·\82×\82Ä\8f\88\97\9d\82·\82é\81B
13  *  (4) \82·\82×\82Ä\8f\88\97\9d\82ª\8fI\82í\82Á\82½\82ç MD5::Final() \82ð\8cÄ\82Ñ\8fo\82µ\81A\8dÅ\8fI\93I\82È MD5 \95\8e\9a\97ñ\82ð\8eó\82¯\8eæ\82é\81B
14  */
15
16 #pragma once
17
18 namespace FDK {
19         namespace General {
20
21 typedef USHORT  UINT2;          // UINT2: \95\84\8d\86\82È\82µ16bit\90®\90\94
22 typedef ULONG   UINT4;          // UINT4: \95\84\8d\86\82È\82µ32bit\90®\90\94
23
24 class MD5
25 {
26 public:
27         void    Init();                                                                         // \8f\89\8aú\89»
28         void    Update( UCHAR* input, ULONG input_len );        // \83\81\83b\83Z\81[\83W\82Ì\8f\88\97\9d
29
30         // \8dÅ\8cã\82Ì\83\81\83b\83Z\81[\83W\95Ï\8a·\81B\8dì\90¬\82³\82ê\82½ MD5 \83R\81[\83h\81i128bit\81j\82ð16\90i\90\94\95\\8bL\82É
31         // \95Ï\8a·\82µ\82½\95\8e\9a\97ñ\81i32\95\8e\9a\81{'\0'\81j\82ª outbuf \82É\8ai\94[\82³\82ê\82é\81B
32         // (\81\88outbuf[] \82Í\8dÅ\92á33\95\8e\9a\88È\8fã\93ü\82é\82±\82Æ\81B\81j
33         void    Final( TCHAR outbuf[] );
34
35         static BYTE             CalcSum( TCHAR* hash );                         // \8ew\92è\82³\82ê\82½\83n\83b\83V\83\85\82Ì\83T\83\80\82ð\8cv\8eZ\82µ\82Ä\95Ô\82·\81B
36         static void             PutBool( BYTE** p, bool b );            // bool \8fo\97Í
37         static void             PutInt( BYTE** p, int n );                      // int \8fo\97Í
38         static void             PutInt64( BYTE** p, __int64 n );        // __int64 \8fo\97Í
39         static void             PutFloat( BYTE** p, float f );          // float \8fo\97Í
40         static void             PutString( BYTE** p, TCHAR* str );      // \95\8e\9a\97ñ\8fo\97Í
41
42 public:
43         MD5() {}
44         virtual ~MD5() {}
45
46 protected:
47         void    Transform();            // \93ü\97Í\83o\83b\83t\83@\82ð\95Ï\8a·\8f\88\97\9d\82µ\81A\82»\82Ì\8c\8b\89Ê\82ð m_state[4] \82É\8ai\94[\82·\82é\81B
48
49 protected:
50         ULONG   m_input_len;            // \93ü\97Í\82Ì\91\8d\83T\83C\83Y
51         UINT4   m_state[4];                     // \8fo\97Í(A,B,C,D)
52         UCHAR   m_buffer[64+1];         // \93ü\97Í\83o\83b\83t\83@(16\83\8f\81[\83h)
53         ULONG   m_buflen;                       // \93ü\97Í\83o\83b\83t\83@\82Ì\97L\8cø\83o\83C\83g\90\94
54
55 };
56
57         }//General
58 }//FDK
59
60 using namespace FDK::General;