Monday, March 23, 2015

C program to check palindrome

Palindrome is a string,which when read in both forward and backward way in same.
Example:-madam,radar,rotavator

#include<stdio.h>
char string_palin(char str[]);

int main()
{
 char str[30];
 clrscr();
 printf("Enter string : ");
 scanf("%s",&str);

 if(string_palin(str))
    printf("Entered string Palindrome");
 else
    printf("Entered string not Palindrome");
    getch();
 return 0;
}

/*function for palindrome*/

char string_palin(char str[])
{
 int i,j;
 for(i=0; str[i]!=NULL; i++);
 for(j=0,i--; j<=i; )
 {
   if(str[i]==str[j])
   {
      i--;
      j++;
   }
  else
      break;
 }
 if(j>i)
    return(1);
 else
    return(0);
}

C program to reverse string using recursion

#include<stdio.h>
void reverse(char*,int,int);

int main()
{
char a[100];
gets(a);
reverse(a,0,strlen(a)-1);
printf("%s\n",a);
return 0;
}

void reverse(char *x,int i,int j)
{
char c;
if(i>=j)
return;
c=*(x+i);
*(x+i)=*(x+j);
*(x+j)=c;

reverse(x,++i,--j);
}

Monday, March 9, 2015

Cryptography


Cryptography is the practice and study of hiding information. It is also called the code, but this is not really a good name. It is a science that is used to keep the information confidential and secure. Modern cryptography is a mix of mathematics, computer science and electrical engineering. Cryptography is used in ATM (banking) cards, computer passwords, and shopping on the internet.


If a message is sent is changed with cryptography (or encrypted) before it is sent. The method of changing the text is a "code" or, rather, as a “cipher”. The amended text is "tagged”. The amendment makes the message difficult to read. Someone who wants to read it should change back (or decrypt). How to change back it's a secret. Both the individual sending the message and the one who receives must change the secret way to know, but others may not. Studying the cypher text called to discover the secret “cryptanalysis” or “cracking" or sometimes “code breaking”.


Different types of cryptography can be easier or harder to use and can be better or worse hide the secret message. Figures use a "key" that is a secret hiding secret messages. The cryptographic method does no secret. Different people may have the same method, but using different keys so that they cannot read each others messages. Since Caesar cipher that so many keys as the number of letters in the alphabet easily cracked by trying all the keys. Figures billions of keys can be cracked by more complex methods.

References

Understanding Cryptography: A Textbook for Students and Practitioners By Christof Paar, Jan Pelzl

Cryptography: Theory and Practice, Third Edition By Douglas R. Stinson

More Books

Computer Viruses