#include
#define uchar unsigned char
#define HOP1 CSR0
#define HOP2 CSR1
#define HOP3 CSR2
#define HOP4 CSR3
uchar KEY0,KEY1,KEY2,KEY3,KEY4,KEY5,KEY6,KEY7;
uchar CSR0,CSR1,CSR2,CSR3,CSR4,CSR5,CSR6,CSR7,CSR8;
uchar CNT0,CNT1,HOP_LENGTH,MASK,KEELOQ_Temp;
bit bb,bb1; } if(testbit(HOP3,3)!=0) if(testbit(HOP2,0)!=0) temp1=HOP4 & 0x42; ;//Bit6 and bit 1 bb=HOP1>0x7f; bb1=HOP2>0x7f; bb=HOP3>0x7f; HOP4<<=1; aa: } } void main(void) }
uchar testbit(uchar x,uchar n)
{
return x & (1<
void decrypt(void)
{
uchar i,j;
uchar temp1,temp;
for(i=0;i<12;i++)
{
for(j=0;j<48;j++)
{
if(i==11)
goto aa;
MASK=0x10;
else
MASK=1;
{
MASK<<=2;
}
if(testbit(HOP1,0)!=0)
MASK<<=1;
switch(temp1)
{
case 0x0:
temp=0x2e;
break;
case 0x02:
temp=0x74;
break;
case 0x40:
temp=0x5c;
break;
case 0x42:
temp=0x3a;
break;
default:
break;
}
if((MASK & temp)==0)
temp=0;
else
temp=0x80;
temp^=HOP2;
temp^=HOP4;
temp^=KEY1;
HOP1<<=1;
if(temp>0x7f) HOP1|=1;
HOP2<<=1;
if(bb) HOP2|=1;
HOP3<<=1;
if(bb1) HOP3|=1;
if(bb) HOP4|=1;
bb=KEY0>0x7f;
KEY0<<=1;
if(KEY7>0x7f) KEY0|=1;
bb1=KEY1>0x7f;
KEY1<<=1;
if(bb) KEY1|=1;
bb=KEY2>0x7f;
KEY2<<=1;
if(bb1) KEY2|=1;
bb1=KEY3>0x7f;
KEY3<<=1;
if(bb) KEY3|=1;
bb=KEY4>0x7f;
KEY4<<=1;
if(bb1) KEY4|=1;
bb1=KEY5>0x7f;
KEY5<<=1;
if(bb) KEY5|=1;
bb=KEY6>0x7f;
KEY6<<=1;
if(bb1) KEY6|=1;
bb1=KEY7>0x7f;
KEY7<<=1;
if(bb) KEY7|=1;
}
{
KEY7=0x01;
KEY6=0x23;
KEY5=0x45;
KEY4=0x67;
KEY3=0x89;
KEY2=0xab;
KEY1=0xcd;
KEY0=0xef;
while(1)
{
CSR3=0X60; ;
CSR2=0;
CSR1=3;
CSR0=0X45; //解码结果87 24 3D 4B
decrypt();
}
上一篇:基于2051单片机串行数据采集传输模块的设计
下一篇:C51的延时函数
推荐阅读最新更新时间:2024-03-16 15:20