LoadRunnerのはMD5メソッドを呼び出します

0.1。MD5アルゴリズムは、最初のファイルmd5.h Cコンパイラを生成するGLOBAL.H、ファイル内の仮想ユーザ・ジェネレータは、その後の#includeを追加し、このファイルmd5.h「md5.h」ヘッダを追加して

 

 

 

globals.h年で参照の#include「md5.h」を追加し、ヘッダファイルmd5.hでLRに追加、次のようにmd5.hコードは次のとおりです。

 


2.メソッド呼び出しMD5:lr_output_message( "%のS"、CMD5( " テスト "))

--- MD5 DLLを生成する方法であってもよく、その後、LRにDLLを呼び出します。(この方法が試されていない)

MD5は、以下:

#ifndefのMD5_H
の#define MD5_H
の#ifdef __alpha
;のtypedef unsigned int型UInt32型
の#else
のtypedef unsigned long型UInt32型;
#endifの
構造体{MD5Context
        するUInt32のBUF [4];
        UInt32型ビット[2];
        符号なし; [64]チャーにおける
};
のexternボイドMD5Init();
のexternボイドMD5Update();
のexternボイドMD5Final();
のexternボイドMD5Transform();
typedefは構造体MD5Context MD5_CTX;
#endifの
#ifdefのSGI
の#define HIGHFIRST
#endifの
#ifdefのサン
#define HIGHFIRST
#endifの
#ifndefのHIGHFIRST
の#define byteReverse(BUF、LEN)/ *何も* /
#elseの
無効byteReverse(BUF、long型)はunsigned char * bufは、符号なしlong型;
{
    UINT32 T。
    実行{
    T =(UINT32)((符号なし)BUF [3] << 8 | BUF [2])<< 16 |((符号なし)BUF [1] << 8 | BUF [0])。
    *(UINT32 *)BUF = T。
    BUF + = 4。
    }一方(--longs)。
}
#endifの
空隙MD5Init(CTX)構造体MD5Context * CTX。
{
    ctx-> BUF [0] = 0x67452301。
    ctx-> BUF [1] = 0xefcdab89。
    ctx-> BUF [2] = 0x98badcfe。
    ctx-> BUF [3] = 0x10325476。
    ctx->ビット[0] = 0;
    ctx->ビット[1] = 0;
}
空MD5Update(CTX、BUF、LEN)構造体MD5Context * CTX。unsigned char型* bufは、符号なしのlen;
{
    UINT32 T。
    T = ctx->ビット[0]。
    IF((ctx->ビット[0] = T +((UINT32)LEN << 3))<T)
    ctx->ビット[1] ++;
    ctx->ビット[1] + = LEN >> 29。
    T =(T >> 3)&0x3fを。
    (T){場合
    はunsigned char * P =(unsigned char型*)ctx-> + Tにおいて、
    T = 64 - T。
    IF(LEN <T){
        のmemcpy(P、BUF、LEN)。
        リターン;
    }
    のmemcpy(P、BUF、T)。
    byteReverse(ctx->で、16)。
    MD5Transform(ctx-> bufが、(UINT32 *)ctx->で);
    BUF + = T。
    LEN - = T;
    }
    一方(LEN> = 64){
    memcpy(ctx->において、BUF、64)。
    byteReverse(ctx->で、16)。
    MD5Transform(ctx-> bufが、(UINT32 *)ctx->で);
    BUF + = 64。
    LEN - = 64;
    }
    のmemcpy(ctx-> BUF、で、LEN)。
}
ボイドMD5Final(CTXダイジェスト)
    unsigned charのダイジェスト[16]。構造体MD5Context * CTX。
{
    符号なしカウント。
    unsigned char型* P;
    カウント=(ctx->ビット[0] >> 3)&は0x3F。
    P = ctx-> +数で、
    * P ++ = 0x80を;
    カウント数= 64 - 1 -数えます。
    (数<8){場合
    のmemset(P、0、カウント)。
    byteReverse(ctx->で、16)。
    MD5Transform(ctx-> bufが、(UINT32 *)ctx->で);
    memsetの(ctx->において、0、56);

    memsetの(P、0、カウント数- 8)。
    }
    byteReverse(ctx->で、14)。
    ((UINT32 *)ctx->で)[14] = ctx->ビット[0]。
    ((UINT32 *)ctx-> IN)[15] = ctx->ビット[1]。
    MD5Transform(ctx-> bufが、(UINT32 *)ctx->で);
    byteReverse((unsigned char型*)ctx-> BUF、4)。
    memcpy(ctx-> BUF、16ダイジェスト)。
    memset(CTX、0、はsizeof(CTX))。
}
の#define F1(X、Y、Z)(Z ^(x&(Y ^ Z)))
の#define F2(X、Y、Z)F1(Z、X、Y)
の#define F3(X、Y、 Z)(x ^ y ^ Z)
の#define F4(X、Y、Z)(Y ^(X |〜Z))
の#define MD5STEP(F、X、Y、Z、データ、W、S)(+ W = F(X、Y、Z)+データ、W = W << S | W >>(32-S)+ = X)W
空隙MD5Transform(BUF、IN)
    UINT32 BUF [4]。UINT32で[16]。
{
    UINT32 A、B、C、Dを登録します。
    A = BUF [0]。
    B = BUF [1]。
    C = BUF [2]。
    D = BUF [3]。
    MD5STEP(F1、中、B、C、D [0] + 0xd76aa478、7)。
    MD5STEP(F1、D、中、B、C、[1] + 0xe8c7b756、12)。
    MD5STEP(F1、でC、D、A、B、[2] + 0x242070db、17)。
    MD5STEP([3] + 0xc1bdceee、22でF1、B、C、D)。
    MD5STEP(F1、中、B、C、D、[4] + 0xf57c0faf、7)。
    MD5STEP(F1、D、A、B、C、[5]に+ 0x4787c62a、12)。
    MD5STEP(F1、でC、D、A、B、[6] + 0xa8304613、17)。
    MD5STEP(F1、B、C、D、[7] + 0xfd469501、22)。
    MD5STEP(F1、中、B、C、D、[8] + 0x698098d8、7)。
    MD5STEP(F1、D、中、B、C、[9] + 0x8b44f7af、12)。
    MD5STEP(F1、でC、D、A、B、[10] + 0xffff5bb1、17)。
    MD5STEP([11] + 0x895cd7be、22でF1、B、C、D)。
    MD5STEP(F1、中、B、C、D [12] + 0x6b901122、7)。
    MD5STEP(F1、D、中、B、C、[13] + 0xfd987193、12)。
    MD5STEP(F1、でC、D、A、B、[14] + 0xa679438e、17)。
    MD5STEP([15] + 0x49b40821、22でF1、B、C、D)。
    MD5STEP(F2、中、B、C、D、[1] + 0xf61e2562、5)。
    MD5STEP([6] + 0xc040b340、9 F2、D、A、B、C)。
    MD5STEP(F2、でC、D、A、B、[11] + 0x265e5a51、14)。
    MD5STEP(F2、B、C、D、[0] + 0xe9b6c7aa、20)。
    MD5STEP(F2、中、B、C、D、[5] + 0xd62f105d、5)。
    MD5STEP([10] + 0x02441453、9 F2、D、A、B、C)。
    MD5STEP(F2、でC、D、A、B、[15] + 0xd8a1e681、14)。
    MD5STEP(F2、B、C、D、[4] + 0xe7d3fbc8、20)。
    MD5STEP(F2、中、B、C、D、[9] + 0x21e1cde6、5)。
    MD5STEP([14] + 0xc33707d6、9 F2、D、A、B、C)。
    MD5STEP(F2、でC、D、A、B、[3] + 0xf4d50d87、14)。
    MD5STEP(F2、B、C、D、[8] + 0x455a14ed、20)。
    MD5STEP(F2、中、B、C、D [13] + 0xa9e3e905、5)。
    MD5STEP([2] + 0xfcefa3f8、9 F2、D、A、B、C)。
    MD5STEP(F2、でC、D、A、B、[7] + 0x676f02d9、14)。
    MD5STEP([12] + 0x8d2a4c8a、20でF2、B、C、D)。
    MD5STEP(F3、中、B、C、D、[5] + 0xfffa3942、4)。
    MD5STEP([8] + 0x8771f681、11においてF3、D、A、B、C)。
    MD5STEP(F3、でC、D、A、B、[11] + 0x6d9d6122、16)。
    MD5STEP([14] + 0xfde5380c、23においてF3、B、C、D)。
    MD5STEP(F3、中、B、C、D、[1] + 0xa4beea44、4)。
    MD5STEP([4] + 0x4bdecfa9、11においてF3、D、A、B、C)。
    MD5STEP(F3、でC、D、A、B、[7] + 0xf6bb4b60、16)。
    MD5STEP([10] + 0xbebfbc70、23においてF3、B、C、D)。
    MD5STEP(F3、中、B、C、D [13] + 0x289b7ec6、4)。
    MD5STEP(F3、D、A、B、C、[0] + 0xeaa127fa、11);
    MD5STEP(F3、でC、D、A、B、[3] + 0xd4ef3085、16)。
    MD5STEP(F3、B、C、D、[6] + 0x04881d05、23)。
    MD5STEP(F3、中、B、C、D、[9] + 0xd9d4d039、4)。
    MD5STEP([12] + 0xe6db99e5、11においてF3、D、A、B、C)。
    MD5STEP(F3、でC、D、A、B、[15] + 0x1fa27cf8、16)。
    MD5STEP(F3、B、C、D、[2] + 0xc4ac5665、23)。
    MD5STEP(F4、中、B、C、D [0] + 0xf4292244、6)。
    MD5STEP([7] + 0x432aff97、10でF4、D、A、B、C)。
    MD5STEP(F4、でC、D、A、B、[14] + 0xab9423a7、15)。
    MD5STEP(F4、B、C、D、[5] + 0xfc93a039、21)。
    MD5STEP(F4、中、B、C、D [12] + 0x655b59c3、6)。
    MD5STEP(F4、D、中、B、C、[3] + 0x8f0ccc92、10)。
    MD5STEP(F4、でC、D、A、B、[10] + 0xffeff47d、15)。
    MD5STEP(F4、B、C、D、[1] + 0x85845dd1、21)。
    MD5STEP(F4、中、B、C、D、[8] + 0x6fa87e4f、6)。
    MD5STEP([15] + 0xfe2ce6e0、10でF4、D、A、B、C)。
    MD5STEP(F4、でC、D、A、B、[6] + 0xa3014314、15)。
    MD5STEP([13] + 0x4e0811a1、21でF4、B、C、D)。
    MD5STEP(F4、中、B、C、D、[4] + 0xf7537e82、6)。
    MD5STEP([11] + 0xbd3af235、10でF4、D、A、B、C)。
    MD5STEP(F4、でC、D、A、B、[2] + 0x2ad7d2bb、15)。
    MD5STEP(F4、B、C、D、[9] + 0xeb86d391、21)。
    BUF [0] + =。
    BUF [1] + = B。
    BUF [2] + = C。
    BUF [3] + = D。
}
のchar * CMD5(CONSTのchar * S)
{
     構造体MD5Context md5c。
     unsigned char型のSS [16]。
     チャーSUBSTR [3]、resStr [33]。
     私はint型。
     MD5Init(&md5c)。
     MD5Update(&md5c、sは、strlenを(S))。
     MD5Final(SS、&md5c)。
     strcpyの(resStr、 "");
     以下のための(I = 0、I <16; I ++)
     {
         のsprintf(SUBSTR、 "%の02X"、SS [I])。
         itoaは(SS [i]が、SUBSTR、16)。
         IF(STRLEN(SUBSTR)== 1){
             STRCAT(resStr、 "0")。
         }
         STRCAT(resStr、SUBSTR)。
     }
     STRCAT(resStr、 "\ 0")。
     resStrを返します。
}

おすすめ

転載: www.cnblogs.com/wsy0202/p/12359006.html