密码应用及c源代码(c++源码加密)
admin 发布:2022-12-19 21:59 113
本篇文章给大家谈谈密码应用及c源代码,以及c++源码加密对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
用C语言编程恺撒密码加密解密程序
#include stdio.h
#define isletter( c ) ( ((c)='a'(c)='z') || ((c)='A'(c)='Z') )
void Enc( const char *str, char *out, int key )
{
int i = 0;
while( str[i] )
{
if ( isletter( str[i] ) )
{
out[i] = str[i] + key;
if ( ! isletter( out[i]) )
out[i] -= 26;
}
else
out[i] = str[i];
i++;
}
out[i] = 0;
}
void Denc( const char *str, char *out, int key )
{
int i=0;
while( str[i] )
{
if ( isletter( str[i] ) )
{
out[i] = str[i] - key;
if ( ! isletter( out[i] ) )
out[i] += 26;
}
else
out[i] = str[i];
i++;
}
out[i] = 0;
}
int main()
{
char out[100], out2[100];
Enc( "THE QUICK BROWn fox jumps over THE LAZY DOG", out, 3 );
printf( "%s\n", out );
Denc( out, out2, 3 );
printf( "%s\n", out2 );
}
悬赏100分 如何用c语言 写一个密码程序
clude "string.h"
//考虑到用数据库文件保存注册信息的话要使用access创建文件并且还要配置数据源,所以我的方法是采用将注册信息保存到文件
//下面是完整的程序:
//登陆检测函数
int login(char *name,char *password)
{
char info[10000];
char *p=info;
FILE *file=fopen("user","r");
int size;
if(file)
{
size=fread(info,1,10000,file);
while(size!=(int)p-(int)info)
{
if(!strcmp(p,name)!strcmp(p+strlen(p)+1,password))
{
fclose(file);
return 1;
}
p+=strlen(p)+1;
p+=strlen(p)+1;
}
}
fclose(file);
return 0;
}
//添加注册信息入文件
void save(char *name,char *password)
{
FILE *file=fopen("user","a");
fwrite(name,1,strlen(name)+1,file);
fwrite(password,1,strlen(password)+1,file);
fclose(file);
}
#define PASSWORD "12345" //这里指定你要允许通过的密码,比如12345,将引号里的数字改为你想要的即可
int main()
{
char password[100];
char name[100],c[100],password1[100];
tag1: printf("press 1 to register, or 2 to login\n");//输入1为注册,输入2为登陆
while(1)
{
gets(c);
if('1'==c[0])
{
printf("please enter your name\n");//输入姓名
gets(name);
tag2: printf("please enter your password\n");//输入密码
gets(password);
printf("please enter your password again\n");
gets(password1);
if(strcmp(password,password1))
{
//两次密码不一致,重输
printf("the password you entered is different from the first one,please try again!\n");
goto tag2;
}
printf("register is completed!\n");//注册成功
//下面实现将注册信息加入文件保存
save(name,password);
goto tag1;
}
else if('2'==c[0])
{
tag3: printf("please enter your name:\n");
gets(name);
printf("please enter your password:\n");
gets(password);
if(login(name,password))//如果验证通过,则
{
printf("login successfully!\n");
//这里添加成功登陆后要执行的代码
}
else
{
printf("your name or password doesn't exist!\n");//否则重输
goto tag3;
}
}
else
{
printf("invalid input!press 1 to register, or 2 to login\n");//输入非法,重输
goto tag1;
}
}
return 0;
}
饿,写了我两个小时啊,大哥,分一定要给我啊~~~~~~
用c语言编写一个设置密码的程序
#include "stdio.h"
int* set(void);
int* set(void)
{
int i;
static a[4];
printf("请输入要设置的4位密码 :");
for(i=0;i4;i++)
{
scanf("%d",a[i]);
}
return a;
}
int main()
{
int i,*a,b[4];
a=set();
printf("请输入4位密码 :");
for(i=0;i4;i++)
{
scanf("%d",b[i]);
}
i=0;
while(i4)
{
if(a[i]==b[i])
{
printf("%d",a[i]);
i++;
}
else
{
break;
}
}
if(i==4)
{
printf("密码正确\n");
}
else
{
printf("密码错误\n");
}
return 0;
}
密码锁c语言编程代码
#include stdio.h
#include string.h
#include stdlib.h
int main()
{
char password[10],password2[10];
memset(password,0,sizeof(password));
memset(password2,0,sizeof(password2));
printf("请设置8位数以内密码:\n\n");
scanf("%s",password);
printf("请设置校验密码:\n\n");
scanf("%s",password2);
if(atoi(password2)==atoi(password))
{
printf("密码输入正确!:\n");
}
else
{
printf("密码输入错误!:\n");
}
return 0;
}
用C语言设计一个加密 解密 密码 的程序。
// playFair 加密 你参考下 ...
#include"stdio.h"
#include"string.h"
#include"stdlib.h"
#define x 50
char MiYao[x],PassWord[x],AddPass[x],Table[5][5],Map[25];
bool Visit[27]={false};
char English[27]="abcdefghijklmnopqrstuvwxyz";
void Input()
{
printf("请输入密钥:\t"); scanf("%s",MiYao);
printf("请输入待加密密码:\t"); scanf("%s",PassWord);
}
void Fun_5x5()
{
int count = 0,V =0;
/*标记密钥内字符为: true*/
for(int i=0;MiYao[i]!='\0';i++)
if(strchr(English,MiYao[i])!=NULL)
Visit[strchr(English,MiYao[i])-English] = true;
/*执行密钥矩阵操作 并标记已使用字符:true*/
for(int i=0;i5;i++)
for(int j=0;j5;j++)
{
if(countstrlen(MiYao))
Table[i][j] = MiYao[count++];
else
{
while(Visit[V] != false) V++;
Table[i][j] = English[V];
Visit[V++] = true;
}
}
puts("∞∞∞密钥矩阵为∞∞∞");
for(int i=0;i5;i++)
{ for(int j=0;j5;j++)
printf("%3c",Table[i][j]);
puts("");
}
puts("∞∞∞∞∞∞∞∞∞∞∞");
}
int IsVisited(char ch)
{
return Visit[strchr(English,ch)-English]; //false 未出现过
}
void TabletoMap()
{ int count=0;
for(int i=0;i5;i++)
for(int j=0;j5;j++)
Map[count++]=Table[i][j];
Map[count]='\0';
}
void Judge()
{
int len = strlen(PassWord),i,j,k;
memset(AddPass,0,sizeof(char));
/*一对对去字母,剩下单个字母,则不变化,直接放入加密串中.*/
if(len%2){
AddPass[len-1] = PassWord[len-1];
len -=1;
}
/*一对中 密钥矩阵中 存在矩阵 eg.ab 先输出a同行顶点在输出b同行顶点*/
int row1,low1,row2,low2,a1,a2;
for(i=0;ilen;i+=2)
{
char c1,c2;
c1 = PassWord[i];
c2 = PassWord[i+1];
/*一对中 两字母相同 无变化*/
/*一对中 有字母不在密钥矩阵中 无变化*/
if(c1 == c2 || ( !IsVisited(c1)||!IsVisited(c2)))
{ AddPass[i] = c1;
AddPass[i+1]=c2;
}else{
a1 = strchr(Map,c1)-Map;
row1 = a1/5; low1 = a1%5;
a2 = strchr(Map,c2)-Map;
row2 = a2/5; low2 = a2%5;
/*一对中 字符出现在同行或同列 简单swap字符*/
if(row1 == row2 || low1 == low2)
{
AddPass[i] = c2;
AddPass[i+1] = c1;
}else{
AddPass[i] = Table[row1][low2];
AddPass[i+1] = Table[row2][low1];
}
}
}AddPass[len+1]='\0';
puts("加密后字符串:");
puts(AddPass);
puts("原串是:");
puts(PassWord);
}
int main()
{
Input();
Fun_5x5();
TabletoMap();
Judge();
return 0;
}
密码应用及c源代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于c++源码加密、密码应用及c源代码的信息别忘了在本站进行查找喔。
版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;
- 上一篇:闪烁代码(文字闪烁代码)
- 下一篇:博客日历代码(日历数据库)
相关推荐
- 05-13aso应用商店优化,aso优化软件
- 05-11自助建站系统源码,自助建站源码php
- 05-07pb超级报表源代码(pb报表工具)[20240507更新]
- 05-07简历源代码可以上传照片的简单介绍[20240507更新]
- 05-07广告切换源代码免费下载(广告切换源代码免费下载安装)[20240507更新]
- 05-06阁楼网源代码(阁楼是什么网站)[20240506更新]
- 05-06源代码管理资源管理器(资源管理器运行代码)[20240506更新]
- 05-06点击弹出密码代码(点击弹出密码代码错误)[20240506更新]
- 05-06人脸识别源代码pdf的简单介绍[20240506更新]
- 05-06包含超市管理系统java源代码的词条[20240506更新]
取消回复欢迎 你 发表评论:
- 标签列表
- 最近发表
- 友情链接