编辑代码

#include <stdio.h>
#define uint32 unsigned int
int main () {
    unsigned int i=0;
    unsigned int j=0;
    /* security constant: F1 F2 F3 F4 F5  seed:s1 s2 s3*/
    // uint32 challengea=0xff359015;// 0xF1 s3 s2 s1
    // uint32 challengeb=0xffffffff;// 0xF5 F4 F3 F2 

    //uint32 challengea=0x6b5013f8;// 0xF1 s3 s2 s1
    //uint32 challengeb=0x9b2e0783;// 0xF5 F4 F3 F2 

    uint32 challengea=0x626E4F63;// 0xF1 s3 s2 s1
    uint32 challengeb=0x505221e5;// 0xF5 F4 F3 F2 

    uint32 key=0xc541a9;
    unsigned char r1;
    unsigned char r2;
    unsigned char r3;
    
    for(i=0;i<32;i++)
    {
      key=(key>>1)|(((key^challengea)<<23)&0x800000);
      if((key&0x800000)>0)
      {
          key^=0x109028;
      }
      challengea>>=1;
     // printf("%x\n",key);
    }
    for(j=0;j<32;j++)
    {
      key=(key>>1)|(((key^challengeb)<<23)&0x800000);
      if((key&0x800000)>0)
      {
          key^=0x109028;
      }
      challengeb>>=1;
     // printf("%x\n",key);
    }
    printf("%x\n",key);
    r1=(key>>4)&0xff;
    r2=((key>>20)&0x0f)|((key>>8)&0xf0);
    r3=((key<<4)&0xf0)|((key>>16)&0x0f);
    printf("%x %x %x\n",r1,r2,r3);

}