c语言编写字符串加密函数 不要写得太难啊#include stdio.h
#include ctype.h
char *encrypt(char *text) {
char c;
char *p = text;
for (; *text; ++text) {
c = *text;
if (isdigit(c))
*text = '0' + '9' - c;
else if (islower(c)) {
c = c + 3;
if (c'z')
c = c - 26;
*text = c;
} else if (isupper(c)) {
c = c + 3;
if (c'Z')
c = c - 26;
*text = c;
}
}
return p;
}
int main() {
char text[100];
printf("输入明文:");
scanf("%s", text);
printf("密文:%s\n", encrypt(text));
getchar();
}
编写函数完成字符串的加密与解密(c语言)?C语言代码和运行结果如下:
输出符合示例,加解密均正确,望采纳~
附源码链接:字符串加解密
c语言编写加密程序#include stdio.h
#include string.h
#include "global.h"
#include "md5.h"
#define S11 7
#define S12 12
#define S13 17
#define S14 22
#define S21 5
#define S22 9
#define S23 14
#define S24 20
#define S31 4
#define S32 11
#define S33 16
#define S34 23
#define S41 6
#define S42 10
#define S43 15
#define S44 21
static void MD5Transform PROTO_LIST ((UINT4 [4], unsigned char
[64]));
static void Encode PROTO_LIST
((unsigned char *, UINT4 *, unsigned int));
static void Decode PROTO_LIST
((UINT4 *, unsigned char *, unsigned int));
static void MD5_memcpy PROTO_LIST ((POINTER, POINTER, unsigned
int));
static void MD5_memset PROTO_LIST ((POINTER, int, unsigned int));
static unsigned char PADDING[64] = {
0x80, 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
};
#define F(x, y, z) (((x)(y)) | ((~x)(z)))
#define G(x, y, z) (((x)(z)) | ((y)(~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
#define ROTATE_LEFT(x, n) (((x)(n)) | ((x)(32-(n))))
#define FF(a, b, c, d, x, s, ac) { (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); (a) = ROTATE_LEFT ((a), (s)); (a) += (b);}
#define GG(a, b, c, d, x, s, ac) { \
(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
void MD5Init (context)
MD5_CTX *context;
{
context-count[0] = context-count[1] = 0;
context-state[0] = 0x67452301;
context-state[1] = 0xefcdab89;
context-state[2] = 0x98badcfe;
context-state[3] = 0x10325476;
}
void MD5Update (context, input, inputLen)
MD5_CTX *context;
unsigned char *input;
unsigned int inputLen;
{
unsigned int i, index, partLen;
index = (unsigned int)((context-count[0]3)0x3F);
if ((context-count[0] += ((UINT4)inputLen3)) ((UINT4)inputLen3))
context-count[1]++;
【加密函数c语言程序 加密文件c语言】 context-count[1] += ((UINT4)inputLen29);
partLen = 64 - index;
if (inputLen = partLen)
{
MD5_memcpy((POINTER)context-buffer[index], (POINTER)input, partLen);
MD5Transform (context-state, context-buffer);
for (i = partLen; i + 63inputLen; i += 64)
MD5Transform (context-state, input[i]);
index = 0;
}
else
i = 0;
MD5_memcpy((POINTER)context-buffer[index], (POINTER)input[i],inputLen-i);
推荐阅读
- H文下载,古代辣文
- weblogic连接oracle数据库,weblogic oracle连接池满了
- 电脑怎么导人家在u盘,电脑怎样传到u盘
- 包含9588棋牌游戏的词条
- linux实现命令 linux实现命令聊天程序,功能包括用户注册,用户登录
- 固态硬盘怎么查看真伪码的简单介绍
- flutter编译的so库,flutter 编译ios
- 主播直播样人,主播的一些直播技巧
- 控制台怎么退出mysql 控制台怎么退出文件