添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

C--随机字符串加密

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int mima(int num,int* b1, int* b2){
	int h_num,l_num;
	if(num == 0){
		return 0;
	h_num = num >> 4;
	l_num = num & 0xff >> 4 ;
	*b1 = h_num+0x41;
	*b2 = l_num+0x41;
	return 0;
int rand_str(){
	char static_str[62] = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	int rand_str_width,rand_str_s, n;
	time_t t;
	char rand_str[13] = {0}; 
	char result_str[33] = {0};
	srand((unsigned) time(&t));
	rand_str_width = rand()%12+1;
	for (n = 0; n< rand_str_width; n++){
		rand_str_s = rand()%64+1;
		rand_str[n] = static_str[rand_str_s];
	for (n = 0; n< 16; n++){
		int b1,b2;
		if(n <sizeof(rand_str) && rand_str[n] != 0){
			mima(rand_str[n],&b1,&b2);
			result_str[n*2]=b1;
			result_str[n*2+1] = b2;	
		}else{
			result_str[n*2]='A';
			result_str[n*2+1]='C';
	printf("========%s=====%d",result_str, sizeof(rand_str));