this is code for encrypting files using c language.
//password encryption program for securing password
//pws v 1.0


#include <conio.h>
#include <stdlib.h>
#include <stdio.h>

//create this directory first D:\Sec_pw (OR as per your system drive names)
//file will be overwritten at each execution of program so use once
//increase array as per need


void main()
{
char buffer[72];
int i,x;
FILE *fp;
fp=fopen("D:\Sec_pw\sec.txt","w+");
clrscr();

printf("Enter code:");
scanf("%d",&x);

for(i=0;i<=71;i++)
{
scanf("%c",&buffer[i]);
//at the time of encryption use following statement
//else make it comment at the time of decryption/original
//copy text from  D:\Sec_pw\sec.txt paste it
//make comment to following statement at the time of decrption
buffer[i]=buffer[i]-x;
}

printf("Encrypted text:");
for(i=0;i<=71;i++)
{
printf("%c",buffer[i]);
fprintf(fp,"%c",buffer[i]);
}

printf("\n");


printf("Decrypted text:");
for(i=0;i<=71;i++)
{
buffer[i]=buffer[i]+x;
printf("%c",buffer[i]);


}

getch();
}

Please help me to make it better. THX.

buffer=buffer-x;

This is encryption? In what country?

He is trying not to laugh.

how to find out ascci of a charactor stored in a variable

@roshan007

Welcome to DaniWeb. You are supposed to make a new thread if you want to ask a question. Your question does not have anything to do with the topic on this thread.

But either way, if a character is stored in a variable, its already in ASCII, since a character is just a number from 0 through 255.

This is encryption? In what country?

He is trying not to laugh.

This program do not meet standards of cryptography. But i just suggest it to use as password protection utility which is simple to implement(You may deny to use as you wish). Further i do not said its final code or maybe im doing it for fun (Hence you can laugh). It dont matters to me.

I am not laughing, Vladimir Putin was trying not to laugh but he eventually didn't. Thing is, its not even cryptography. Its not even close. Its not even close to being close.

Say you chose a code that resolved to 1, very possible considering the result is casted to char, an 8 bit number, capable only to be 0 through 255. The final product will look nearly the same, and anyone can see that and say "oh, they just subtracted all the characters by 1". You would have to pick a code within a very small range to cause your encryption to hide the text, but one of the first things any hacker will do is check for patterns, and that range is itself a dead give-away. I just hope you don't ever use this method for something serious because it wouldn't work.

I am being critical about this because you asked for help making it better, but it can't be better, it has to be rewritten from scratch. This is not something to build upon like a template. Any good encryption is based on a good algorithm first, and coded second. What you are doing is coding first and trying to get a good algorithm second. It doesn't work that way.

commented: well..well +1
commented: Yes I agree +3

I am not laughing, Vladimir Putin was trying not to laugh but he eventually didn't. Thing is, its not even cryptography. Its not even close. Its not even close to being close.

Say you chose a code that resolved to 1, very possible considering the result is casted to char, an 8 bit number, capable only to be 0 through 255. The final product will look nearly the same, and anyone can see that and say "oh, they just subtracted all the characters by 1". You would have to pick a code within a very small range to cause your encryption to hide the text, but one of the first things any hacker will do is check for patterns, and that range is itself a dead give-away. I just hope you don't ever use this method for something serious because it wouldn't work.

I am being critical about this because you asked for help making it better, but it can't be better, it has to be rewritten from scratch. This is not something to build upon like a template. Any good encryption is based on a good algorithm first, and coded second. What you are doing is coding first and trying to get a good algorithm second. It doesn't work that way.

Thx for suggestions i'm agree with your comment.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.