Проверьте пожалуста
#include "stdafx.h"
#include <iostream>
#include <string.h>
#include <stdlib.h>
using namespace std;
unsigned char TaktLRR(unsigned char *f, unsigned int &State)
{
unsigned char Bit, Sj;
Bit=State&1;
Sj=(State&1)^(State&1<<(f[0]-f[1]))>>(f[0]-f[1]);
If(f[2]&&f[3])
{
Sj^=(State&1<<(f[0]-f[2]))>>(f[0]-f[2]);
Sj^=(State&1<<(f[0]-f[3]))>>(f[0]-f[3]);
}
State>>=1;
State=State|Sj<<(f[0]-1);
return Bit;
}
unsigned char GenByteLRP(unsigned char*f, unsigned int State_0)
{
int i=0;
unsigned int State=State_0;
unsigned char Byte=0,Bit;
for(i=0;i<8;i++)
{
Bit=TaktLRR(f,State);
Byte|=Bit<<I;
}
return Byte;
}
unsigned char Generate(unsigned char*Key1, unsigned char*Key2)
{
int i=0;
int masKey[32];
for(i=0;i<32;i++)
{
if(GenByteLRP(f1,Key1)=1)
{
masKey=GenByteLRP(f2,Key2);
}
else
{
continue;
}
return masKey;
}
unsigned char Cript(unsigned char *Message, unsigned char len)
{
unsigned char cript = masKey;
unsigned char i;
while (len--)
{
cript ^= *Message++;
for (i = 0; i < 8; i++)
cript = cript & 0x80 ? (cript << 1) ^ 0x31 : cript << 1;
}
return cript;
}
int main()
{
unsigned char Key1[16];
unsigned char Key2[16];
unsigned char Message[];
unsigned char lenMessage;
cout<<’input message’;
cin.getline>>Message;
unsigned char f1[3]={4,3,2};
unsigned char f2[3]={6,3,1};
lenMessage=(int)strlen((char *)Message);
cout<<’input Key1’;
cin.getline(Key1,16);
cin.getline(0);
cout<<’input Key2’;
cin.getline(Key2,16);
cin.getline(0);
Generate(Key1,Key2);
Cript(Message,lenMessage);
stdout<<cript;
}