火影忍者究极冲击3任务模式求教

火影忍者究极冲击

一半 一半
回答
  • 胡拉黑 胡拉黑

    用c语言实现md5算法用c语言实现md5算法,这个够复杂。用c语言实现md5算法.
    1)global.h 头文件
    ifndef prototypes
    define prototypes 0
    endif
    pointer defines a generic pointer type*/
    typedef unsigned char*pointer;uint4 defines a four byte word*/
    typedef unsigned long int uint4;proto_l**t ** defined depending on how prototypes ** defined
    above.if using prototypes,then proto_l**t returns the l**t,otherw**e
    it returns an empty l**t.*/
    if prototypes
    define proto_l**t(l**t)l**t
    else
    define proto_l**t(l**t)()
    endif
    2)md5.h 头文件
    md5 context.*/
    typedef struct {
    uint4 state[4];state(abcd)*/
    uint4 count[2];number of bits,modulo 2^64(l** first)*/
    unsigned char buffer[64];input buffer*/
    } md5_ctx;void md5init proto_l**t((md5_ctx*));void md5update proto_l**t
    ((md5_ctx*,unsigned char*,unsigned int));void md5final proto_l**t((unsigned char[16],md5_ctx*));3)md5c.c 算法的核心部分
    参考 rsa data security,inc.,md5 **-digest algorithm 的c源程

    include"global.h
    include"md5.h
    md5的主循环的轮主要操作为a=b+((a+f(b,c,d)+m+t)值如下:
    define s11 7
    define s12 12
    define s13 17
    define s14 22
    define s21 5
    define s22 9
    define s23 14
    define s24 20
    define s31 4
    define s32 11
    define s33 16
    define s34 23
    define s41 6
    define s42 10
    define s43 15
    define s44 21
    函数调用说明*/
    static void md5transform proto_l**t((uint4[4],unsigned char[64]));static void encode proto_l**t
    ((unsigned char*,uint4*,unsigned int));static void decode proto_l**t
    ((uint4*,unsigned char*,unsigned int));static void md5_memcpy proto_l**t((pointer,pointer,unsigned
    int));static void md5_memset proto_l**t((pointer,int,unsigned int));static unsigned char padding[64]={
    0x80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    };f,g,h and i 是md5的基本函数.
    define f(x,y,z)(((x)&(y))|((~x)&(z)))
    define g(x,y,z)(((x)&(z))|((y)&(~z)))
    define h(x,y,z)((x)^(y)^(z))
    define i(x,y,z)((y)^((x)|(~z)))
    rotate_left将 x 循环左移n bits.*/
    define rotate_left(x,n)(((x)(32-(n))))
    ff,gg,hh,and ii 代表1,2,3,4轮计算,先宏定义以便于后面引用.
    define ff(a,b,c,d,x,s,ac){ \
    (a)+f((b),(c),(d))+(x)+(uint4)(ac);\
    (a)=rotate_left((a),(s));\
    (a)+(b);\
    }
    define gg(a,b,c,d,x,s,ac){ \
    (a)+g((b),(c),(d))+(x)+(uint4)(ac);\
    (a)=rotate_left((a),(s));\
    (a)+(b);\
    }
    define hh(a,b,c,d,x,s,ac){ \
    (a)+h((b),(c),(d))+(x)+(uint4)(ac);\
    (a)=rotate_left((a),(s));\
    (a)+(b);\
    }
    define ii(a,b,c,d,x,s,ac){ \
    (a)+i((b),(c),(d))+(x)+(uint4)(ac);\
    (a)=rotate_left((a),(s));\
    (a)+(b);\
    }
    md5 的初始化,md5 操作的开始.*/
    void md5init(context)
    md5_ctx*context;context*/
    {
    context->count[0]=context->count[1]=0;给出4个32比特的初始向量.*/
    context->state[0]=0x67452301;context->state[1]=0xefcdab89;context->state[2]=0x98badcfe;context->state[3]=0x10325476;}
    md5 块更新操作.不断地对消息块进行md5 消息-摘要操作,并更新
    context.
    void md5update(context,input,inputlen)
    md5_ctx*context;context*/
    unsigned char*input;input block*/
    unsigned int inputlen;length of input block*/
    {
    unsigned int i,index,partlen;compute number of bytes mod 64*/
    index=(unsigned int)((context->count[0]>>3)&0x3f);update number of bits*/
    if((context->count[0]+((uint4)inputlen))
    ((uint4)inputlen context->count[1]+((uint4)inputlen>>29);partlen=64-index;transform as many times as possible.
    if(inputlen>=partlen){
    md5_memcpy
    ((pointer)&context->buffer[index],(pointer)input,partlen);md5transform(context->state,context->buffer);for(i=partlen;i+63 state,&input);index=0;}
    else
    i=0;buffer remaining input*/
    md5_memcpy
    ((pointer)&context->buffer[index],(pointer)&input,
    inputlen-i);}
    md5 的结束操作.输出128比特的散列值并对context归零.
    void md5final(digest,context)
    unsigned char digest[16];** digest*/
    md5_ctx*context;context*/
    {
    unsigned char bits[8];unsigned int index,padlen;s**e number of bits*/
    encode(bits,context->count,8);pad out to 56 mod 64.
    index=(unsigned int)((context->count[0]>>3)&0x3f);padlen=(index state,16);zeroize sensitive **rmation.
    md5_memset((pointer)context,0,sizeof(*context));}
    对一个消息块的16个子块进行md5 基本计算.
    static void md5transform(state,block)
    uint4 state[4];unsigned char block[64];{
    uint4 a=state[0],b=state[1],c=state[2],d=state[3],x[16];decode(x,block,64);round 1*/
    ff(a,b,c,d,x[0],s11,0xd76aa478);1*/
    ff(d,a,b,c,x[1],s12,0xe8c7b756);2*/
    ff(c,d,a,b,x[2],s13,0x242070db);3*/
    ff(b,c,d,a,x[3],s14,0xc1bdceee);4*/
    ff(a,b,c,d,x[4],s11,0xf57c0faf);5*/
    ff(d,a,b,c,x[5],s12,0x4787c62a);6*/
    ff(c,d,a,b,x[6],s13,0xa8304613);7*/
    ff(b,c,d,a,x[7],s14,0xfd469501);8*/
    ff(a,b,c,d,x[8],s11,0x698098d8);9*/
    ff(d,a,b,c,x[9],s12,0x8b44f7af);10*/
    ff(c,d,a,b,x[10],s13,0xffff5bb1);11*/
    ff(b,c,d,a,x[11],s14,0x895cd7be);12*/
    ff(a,b,c,d,x[12],s11,0x6b901122);13*/
    ff(d,a,b,c,x[13],s12,0xfd987193);14*/
    ff(c,d,a,b,x[14],s13,0xa679438e);15*/
    ff(b,c,d,a,x[15],s14,0x49b40821);16*/
    round 2*/
    gg(a,b,c,d,x[1],s21,0xf61e2562);17*/
    gg(d,a,b,c,x[6],s22,0xc040b340);18*/
    gg(c,d,a,b,x[11],s23,0x265e5a51);19*/
    gg(b,c,d,a,x[0],s24,0xe9b6c7aa);20*/
    gg(a,b,c,d,x[5],s21,0xd62f105d);21*/
    gg(d,a,b,c,x[10],s22,0x2441453);22*/
    gg(c,d,a,b,x[15],s23,0xd8a1e681);23*/
    gg(b,c,d,a,x[4],s24,0xe7d3fbc8);24*/
    gg(a,b,c,d,x[9],s21,0x21e1cde6);25*/
    gg(d,a,b,c,x[14],s22,0xc33707d6);26*/
    gg(c,d,a,b,x[3],s23,0xf4d50d87);27*/
    gg(b,c,...

类似问答
精品推荐

友情链接

友链互换QQ:

谷财 备案编号:蜀ICP备11019336号-3商务合作:235-677-2621

Copyright 2009-2020 Chengdu Sanzilewan Technology Co.,Ltd all rights reserve

抵制不良游戏 拒绝盗版游戏 注意自我保护 谨防受骗上当 适度游戏益脑 沉迷游戏伤身 合理安排时间 享受健康生活