加密算法:每一字符与15异或实现低四位取反高四位保持不变。#include stdlibh#include stringh#define LENGTH 81int mainvoid char p; char q; p = charmallocsizeofcharLENGTH; strcpyp I am a student!; ; while p
加密算法实现代码如下:
#include <stdlib.h> #include <string.h> #define LENGTH 81
int main(void)
{
char *p;
char q;
p = (char)malloc(sizeof(char)LENGTH);
strcpy(p, "I am a student!");
q = (char)malloc(sizeof(char)*LENGTH);
char temp;
int high, low;
while (*p) {
temp = *p ^ 15;
high = (temp & 0xf0) >> 4;
low = (temp & 0x0f) ^ 0x0f;
*q = ((high << 4) | low);
p++;
q++;
}
*q = '\0';
puts(q-strlen("I am a student!"));
free(p);
free(q);
return 0;
原文地址: https://www.cveoy.top/t/topic/diZI 著作权归作者所有。请勿转载和采集!