⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clock_setup.cpp

📁 MICKEY 2.0 STREAM CIPHER IMPLEMENTATION IN VISUAL C++
💻 CPP
字号:
#include<iostream.h>
#include "IV_LOAD.h"
#include "CLOCKS.h"
#include<stdio.h>

int R[100];
int S[100];
int Z[800];//keystream

void main (void)
{
int i=0;
cout<<"***********************--------------------------------************************\n";
cout<<"***********************| ' MICKEY 2.0 STREAM CIPHER ' |************************\n";
cout<<"***********************--------------------------------************************\n";
int IV[80];
for (i=0;i<80;i++)
IV[i]=0;
IV_LOAD(IV);//FUNCTION FOR LOADING INITIALIZATION VARIABLE FROM FILE

for (i=0;i<80;i++)
cout<<IV[i];
cout<<"------------------------------------"<<i<<" BITS ------------------------------------\n";

	cout<<endl;


int K[80];
for (i=0;i<80;i++)
K[i]=0;

SECRET_KEY_LOAD(K);//FUNCTION FOR LOADING SECRET KEY FROM FILE
for (i=0;i<80;i++)
cout<<K[i];
cout<<"------------------------------------"<<i<<" BITS ------------------------------------\n";

int mixing=1;

//INITIALIZE R & STO ZEROS(000000000000000000.......)
for(i=0;i<100;i++)
{ R[i]=0;	S[i]=0;
}

//LOAD IN , IV  -------  //ivLength=80
for(i=0;i<80;i++)
CLOCK_KG(R,S,mixing,IV[i]);

//LOAD IN , SECRET_KEY (K)  --------  //length K=80
for(i=0;i<80;i++)
CLOCK_KG(R,S,mixing,K[i]);

//PRE-CLOCK
for(i=0;i<100;i++)
CLOCK_KG(R,S,mixing,0);

for(i=0;i<800;i++)
{ Z[i]=0;
//cout<<Z[i]<<R[i]<<S[i]<<endl;
}

cout<<"\n\n\t\t\t     '800-BIT KEYSTREAM IS' \n"<<endl;
for(i=0;i<800;i++)
{
	Z[i]=R[0]^S[0];
	CLOCK_KG(R,S,0,0);
	cout<<Z[i];
}
cout<<endl;

int text[1200];
for(i=0;i<1200;i++)
text[i]=0;

TEXT_LOAD(text);//FUNCTION FOR LOADING PLAIN TEXT FROM FILE

int a[800],b[800];

//cout<<"\n\n\t\t'ORIGINAL TEXT IS' \n"<<endl;
for(i=0;i<800;i++)
{
	a[i]=text[i]^Z[i];//encoded binary
	
	b[i]=a[i]^Z[i];//decoded binary
   
}

char l[150]={'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','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','0','0','0','0','0','0','0','0','0','0','0','0','0','0',
			 '0','0','0','0','0','0','0','0','0','0'};

bin_2_hex(l,a,sizeof(l),sizeof(a)/4);
cout<<"\n\n\t\t\t       'ENCODED TEXT IS' \n"<<endl;
for(i=0;i<100;i++)
cout<<l[i];
cout<<endl;

char n[150]={'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','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','0','0','0','0','0','0','0','0','0','0','0','0','0','0',
			 '0','0','0','0','0','0','0','0','0','0'};

bin_2_hex(n,b,sizeof(n),sizeof(b)/4);
cout<<"\n\n\t\t\t      'DECODED TEXT IS' \n"<<endl;
for(i=0;i<100;i++)
cout<<n[i];
cout<<"\n\n\n";

}//PROGRAM ENDS HERE



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -