📄 newencryptionanddecryption.cpp
字号:
//Description : The following C code can encrypt any sort of file be it be a sound,image,video or etc
/* A simulated C program to encrypt or decrypt a file with L=26, K=3 and
Buffer Stream Divisions=2 as per described approach */
/*
Few Notations used
R-Read
W-write
*/
#include<string.h>
#include<stdio.h>
#include<conio.h>
#include<process.h>
#include"fcntl.h"
#include"types.h"
#include"stat.h"
#include<io.h>
#include<ctype.h>
#include<time.h>
#include<stdlib.h>
/*Procedure to copy a buffer stream content to another
unsigned char *strcp(unsigned char buf[],unsigned char l[],unsigned int
byt)
{
for(int i=0;i<byt;i++)
buf[i]=l[i];
buf[i]=0;
return(buf);
}
Procedure To reverse buffer stream content*/
unsigned char *strrever(unsigned char buf[],unsigned int byt)
{
unsigned char l[1024];
for(int i=byt-1;i>=0;i--)
l[i]=buf[i];
l[i]=0;
for(i=0;i<byt;i++)
buf[i]=l[i];
buf[i]=0;
return(buf);
}
// Procedure Jumble Buffer stream content
unsigned char *strjab(unsigned char buf[],unsigned int byt,unsigned
char
parts,unsigned char comb)
{
unsigned char k[1024],l[1024],x[1024],y[1024];
int hlen,i,j,len,n=0;
if(parts==2&&comb==2)
{
len=byt;
hlen=len/2;
for(i=0;i<hlen;i++)
k[i]=buf[i];
k[i]=0;
j=i;
for(i=hlen;i<len;i++)
{l[n]=buf[i];n++;}
l[n]=0;
for(i=0;i<j;i++)
l[n+i]=k[i];
l[n+i]=0;
for(i=0;i<len;i++)
buf[i]=l[i];
buf[i]=0;
}
else if(parts==4)
{
}
strrever(buf,byt);
return(buf);
}
/*
A procedure to Encrypt a given file of any format
taking parameter name of the as parameter.
*/
int encrypt(unsigned char *p)
{
unsigned char buf[1024]; /* buf is a buffer where
data of file is R/W */
int in,out,i; /* 'in' is a handle to a file which is for R a file 'out'
is a
handle to a file which is for W a file,
'i' is a
counter */
unsigned int byt;
z:in=open(p,O_RDONLY|O_BINARY); /* Opening given file
in R mode */
out=open("
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -