コード例 #1
0
ファイル: rc4.c プロジェクト: IrlanFreitas/C
int main(void){
	uchar s[256];
	uchar key[256];
	uchar word[256];
	size_t key_len;

	struct dynamic_str encode, decode;

	strcpy((char *)key, "do_or_die"); // > 255 == stack overflow
	strcpy((char *)word, "\natirei o pau na dilma, mas a dilma não morreu\n");

	key_len = strlen((const char *)key);

	ksa(s, key, key_len);
	prga(word, s, &encode);

	printf("RC4:\n'%s'\n", encode.ptr);

	ksa(s, key, key_len);
	prga(encode.ptr, s, &decode);

	printf("Decoded:\n'%s'\n", decode.ptr);

	free(decode.ptr);
	free(encode.ptr);

	return 0;
}
コード例 #2
0
ファイル: rc4new.c プロジェクト: harshapps/NITWCSE-programs
int main()
{
	char s[256];
	char *text = (char *) malloc(256);
	char *key = (char *) malloc(256);
	char *stream = (char *) malloc(256);
	char *enc = (char *) malloc(256);
	char *dec = (char *) malloc(256);

	int p;
	printf("Enter Plain Text : ");       
    scanf("%s",text);
    printf("Enter your KEY : ");
    scanf("%s",key);
	

	ksp(s,key,strlen(key));
	prga(s,stream,strlen(key));

	printf("\nThe Encrypted Text : ");
	for(p=0;p<strlen(text);p++)
	{
		enc[p] = stream[p] ^ text[p];
	}
	printf("%s\n",enc);        

	printf("\nThe Decrypted Text : ");
	for(p=0;p<strlen(text);p++)
	{
		dec[p] = stream[p] ^ enc[p];
	}
	printf("%s\n",dec);        

	return 0;
}