Monday, April 2, 2012

Write a program of Transposition Cipher


import java.io.*;
public class ColumnTransSender
{
            String columns1[]={"","","","",""};
           
            public static void main(String s[])
            {
                        String columns[]={"","","","",""};
                        String key="21403";
                        String msg = "My name is Shreyansh";
                        String result = "";
                        int i;
                        for(i = 0; i < msg.length(); i++)
                                     columns[i % key.length()] += msg.charAt(i);

                        for(i=i%key.length();i<key.length();i++)
                                    columns[i] += "a";

                        for(i = 0; i < key.length(); i++)
                                    System.out.println("Data is : " +  columns[i]);
                                   
                        for(i = 0; i < key.length(); i++)
                        {
                                    result += columns[Integer.parseInt(""+key.charAt(i))];
                        }
                                   
                        System.out.println("Data in Result : " + result);
                        ColumnTransSender d = new ColumnTransSender();
                        d.decrypt(result,key);
            }
           
            public void decrypt(String result,String key)
            {          int i=0;
                        for(int j = 0; j<key.length();j++,i+=Integer.parseInt(""+result.length()/key.length()))
                        {
                                     columns1[Integer.parseInt(""+key.charAt(j))] += result.substring(i,i+Integer.parseInt(""+result.length()/key.length()));
                        }
                       
                                     
                        for( i = 0; i < columns1.length; i++)
                                    System.out.println("Data in again : " +  columns1[i]);
            }
}

Thursday, March 1, 2012

Write a Program of Uthopia Protocol

//Header.c

include
#include
char str[100];
void from_network_layer()
{
printf("Enter the data :");
scanf("%s",str);
}
void to_network_layer()
{
printf("Received data is : %s\n",str);
}
int from_physical_layer(int pid)
{
read(pid,str,100);
}
void to_physical_layer(int pid)
{
write(pid,str,100);
}


//Receiver.c
#include "header.c"
main()
{
int pid;
mkfifo("pipe_data",0666);
pid=open("pipe_data",O_RDONLY);
//printf("ok......\n");
while(from_physical_layer(pid))
{
to_network_layer();
}
close(pid);
unlink("pipe_data");
}

//Sender.c
#include "header.c"
#include "header.c"
main()
{
int pid,no,i;
pid=open("pipe_data",O_WRONLY);
printf("Enter the no of frames you want to enter :");
scanf("%d",&no);
for(i=0;i

Saturday, February 25, 2012

Write a program for Bit stuffing(Write a code for sender and receiver side both)

/* sender- Bit stuffing*/

#include
#include
#include
main()
{
int pid,i,fno,cnt,k,j;
char flag[]="01111110";
char frm[100],frm1[100]="",packet[100]="";
system("clear");
pid=open("pipe",O_WRONLY);
printf("Enter The Frame : ");
scanf("%d",&fno);
printf("\t\tEnter The Binary Data\n");
for(i=0;i/* sender- Bit stuffing*/

#include
#include
#include
main()
{
int pid,i,fno,cnt,k,j;
char flag[]="01111110";
char frm[100],frm1[100]="",packet[100]="";
system("clear");
pid=open("pipe",O_WRONLY);
printf("Enter The Frame : ");
scanf("%d",&fno);
printf("\t\tEnter The Binary Data\n");
for(i=0;i

Write a program for Byte stuffing framing method.(Code for sender and receiver side both)

/* Sender.c - Byte Stuffing*/

#include
#include
#include
main()
{
int fno,i,pid,k=0,j=0;
char str[100],packet[100]="",*ch,str1[100];
ch=(char *)malloc(sizeof(char));
ch[0]='$';
system("clear");
pid=open("pipe",O_WRONLY);
printf("Enter The No. Of Frame : ");
scanf("%d",&fno);
for(i=0;i/* receiver- Byte Stuffing*/

#include
#include
#include
main()
{
int pid,cnt=0,i=1;
char packet[100],ch='$';
system("clear");
mkfifo("pipe",0666);
pid=open("pipe",O_RDONLY);
read(pid,packet,100);
printf("%s\n\n",packet);
while(packet[cnt]!='\0')
{
if(packet[cnt]=='$'&& packet[cnt-1]!=='#')
{
cnt++;
}
else
{
printf("Frame %d : ",i);
i++;
while(packet[cnt]!='$')
{
if(packet[cnt]=='#')
{
cnt++;
}
printf("%c",packet[cnt]);
cnt++;
}
}
printf("\n");
}
close(pid);
unlink("pipe");
}

Write a program for character counter. (Sender and receiver both side)

/* Sender- Character count */

#include
#include
#include
#include
int main()
{
int pid,no,cnt=0;
char str[50],packet[100]="",*len;
system("clear");
len=(char *)malloc(sizeof(char));
pid=open("pipe",O_WRONLY);
printf("How Many Frames U Wnt To Enter : ");
scanf("%d",&no);
while(cnt/* Receiver - character count*/

#include
#include
#include
main()
{
int pid,cnt=0,len=0,i,k=1,j;
char packet[100],frame[100];
system("clear");
mkfifo("pipe",0666);
pid=open("pipe",O_RDONLY);
read(pid,packet,100);
printf("\nData Received Is : %s\n",packet);
while(packet[cnt]!=NULL)
{
len=packet[cnt]-48;
printf("\nFrame %d : ",k);
for(i=cnt+1,j=0;i

Wednesday, February 1, 2012

2 programs of FON.

1)Write a program to convert character to binary with ASCII.

#include
#include
void main()
{
int n1,c,i,rev[10],j=0;
char ch;
clrscr();

printf("Enter a Character:");
scanf("%c",&ch);
n1=(int)ch;
printf("The ASCII of %c is %d ",ch,n1);
c=n1;
while(c!=0)
{
i=c%2;
c/=2;
rev[j++]=i;
}
printf("Binary of %c is \n",ch);
for(i=j-1;i>=0;i--)
{
printf("%d",rev[i]);
}
getch();
}



2)Write a program to covert a decimal number into a binary number.

#include
#include
void main()
{
int n1,i;
int b1[10],c;
int j=0;
clrscr();
printf("Enter a number:");
scanf("%d",&n1);
c=n1;
while(c!=0)
{
i=c%2;
c/=2;
b1[j++]=i;
}
for(i=j-1;i>=0;i--)
{
printf("%d",b1[i]);
}
getch();
}

Something Useful

Dear Friends!

Below, I have mention some links which is useful for different purpose, I have also mention the purpose and what you can with use of that links.

1) www.khanacademy.org ----- Online video on any topic of any course. You can learn maths and all...

2)www.msdn.microsoft.com/en-us/library --- With use of this MSN link you can use all type of examples of ASP.net and etc...

3) www.freehindiradio.com/listen-red-fm-online ----- With use of this link, you can heard online radio but first you have to download frequency file of that station...

4) www.jquery.com ------- with use this link, you can find the video of j-query and you can learn also. There are also some examples of j-query. From that, you can use j-queey and download for your application to design...

$