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

📄 xor.c

📁 python的加密库
💻 C
字号:
/* *  xor.c : Source for the trivial cipher which XORs the message with the key. *          The key can be up to 32 bytes long. * * Part of the Python Cryptography Toolkit * * Distribute and use freely; there are no restrictions on further  * dissemination and usage except those imposed by the laws of your  * country of residence. * */#define MODULE_NAME XOR#define BLOCK_SIZE 1#define KEY_SIZE 0typedef struct {	unsigned char key[32];	int keylen, last_pos;} stream_state;static voidstream_init(stream_state *self, unsigned char *key, int len){	int i;  	if (32 <= len) len=32;	self->keylen = len;	self->last_pos = 0;	for(i=0; i<len; i++)	{		self->key[i] = key[i];	}}/* Encryption and decryption are symmetric */#define stream_decrypt stream_encrypt	static void stream_encrypt(stream_state *self, unsigned char *block, 			   int len){	int i, j = self->last_pos;	for(i=0; i<len; i++, j=(j+1) % self->keylen)	{		block[i] ^= self->key[j];	}	self->last_pos = j;}#include "stream_template.c"

⌨️ 快捷键说明

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