예제 #1
0
파일: test.c 프로젝트: jason6020/rc4_string
int main(int argc, char *argv[]) {
	
	char *key = "jason";
	char *in = "how are you?";
	char out1[256] = {0};
	char out2[256] = {0};

	rc4_init(key, strlen(key));
	rc4_encode(in, strlen(in), out1);

	printf("out1 => %s\n", out1);

	rc4_init(key, strlen(key));
	rc4_encode(out1, strlen(out1), out2);

	printf("out2 => %s\n", out2);

	return 0;
}
예제 #2
0
int rkcommon_set_header(void *buf, uint file_size,
			struct image_tool_params *params)
{
	struct header0_info *hdr;

	if (file_size > rkcommon_get_spl_size(params))
		return -ENOSPC;

	memset(buf,  '\0', RK_INIT_OFFSET * RK_BLK_SIZE);
	hdr = (struct header0_info *)buf;
	hdr->signature = RK_SIGNATURE;
	hdr->disable_rc4 = 1;
	hdr->init_offset = RK_INIT_OFFSET;

	hdr->init_size = (file_size + RK_BLK_SIZE - 1) / RK_BLK_SIZE;
	hdr->init_size = (hdr->init_size + 3) & ~3;
	hdr->init_boot_size = hdr->init_size + RK_MAX_BOOT_SIZE / RK_BLK_SIZE;

	rc4_encode(buf, RK_BLK_SIZE, rc4_key);

	return 0;
}