| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 494 人关注过本帖
标题:文件的加密和解密
只看楼主 加入收藏
北纬以北
Rank: 1
等 级:新手上路
帖 子:4
专家分:2
注 册:2014-12-27
结帖率:0
收藏
 问题点数:0 回复次数:1 
文件的加密和解密
运行文件加密程序,输入要加密的文件名,然后输入密码,最后输入加密后的文件名,程序对文件中读入的每一个字符与密码进行疑惑,再将疑惑后的内容倒序写入指定的文件中。
解密程序为加密程序的逆过程。
请使用链栈的结构设计并完成程序的功能。
搜索更多相关主题的帖子: 文件加密 输入密码 
2014-12-28 21:48
北纬以北
Rank: 1
等 级:新手上路
帖 子:4
专家分:2
注 册:2014-12-27
收藏
得分:0 
#include<stdio.h>
#include<stblid.h>
#define MAXSIZE 100
typedef struct snode{
    char a[MAXSIZE];
    struct snode *next;
}StackNode,*LinkStack;
LinkStack top;

void Error(char *s)//自定义错误处理函数
{
    printf("%S",s);
    exit(1);
}
void Fprint(FILE *fp,LinkStack top)//输入文件
{
    int i=0;
    LinkStack p;
    while(p)
    {
        fprintf(fp,"%s\n",p->a[i]);
        p=p->next;
    }
}
void encrypt(char *pwd)//加密
{
    int i;
    for(i=0;i<strlen(pwd);i++)
    paw[i]=pwd[i]^15;
}
/*倒叙*/
LinkStack Init()//置栈空
{
    LinkStack top;
    top=(LinkStack)malloc(sizeof(StackNode));
    top->next=NULL;
    return top;
}
int Empty(LinkStack top)//判栈空
{
    return top->next==NULL;
}
void Push(LinkStack top,char [])//入栈
{
    int i=0;
    LinkStack p;
    FILE *fin;
    if((fin=fopen("a.txt","r"))==NULL);
    {
        printf("file error!");
        exit(-1);
    }
    while(!feof(fin))
    {
        p=(LinkStack)malloc(sizeof(StackNode));
        fscanf(fin,"%s",p->a[i]);
        p->next=top->next;
        top->next=p;
    }
    fclose(fin);
}
datatype Pop(LinkStack top)//出栈
{
    LinkStack p;
    datatype x;
    if(Empty(top))
    Error("Stack is Empty");
    p=top->next;
    x=p->info;
    top->next=p->next;
    free(p);
    return x;
}
除了主函数外和解密外,还缺一些什么?解密怎么写?求大神解答
2014-12-28 22:09
快速回复:文件的加密和解密
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017249 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved