Saturday 31 December 2011

Truth of Earth in 2012

It is just a fable that earth will meet its end on 21st December 2012. There is no possibility of earth meeting its catastrophe. There is no planetary or asteroidal movements that can strike the earth in future years. This is the day of winter solstice. This favle actually rose from fact that Sumerians discovered a planet that would have struck in May 2003 and this day was forwarded to 2012. But all this are baseless. NASA is regularly observing planetary movements. All this were actually connected with the fact that ancient Mayan Calendar will end in 2012. But this just like 1st January after 31st December, so next long count of Mayan Calendar will begin after 2012. Even the fact of polar shift is also baseless. This is because it is never possible for Earth to rotate in the reverse direction.

To know more Click here to go to NASA website

Monday 26 December 2011

Encryption Software with Java

This software is used for encrypting or decrypting a file with and without password. Files encrypted with this software cannot be decrypted with others or others with this one because of difference in keys.
Requirements : Java Run Time Environment must be installed on your computer.

Click to DOWNLOAD the software version 1.0 from 4shared.com
Click to DOWNLOAD Encrypter Version 2.0 from 4shared.com

Java program to encrypt/decrypt a file with password

Java can be very efficiently in encrypting files in DES mode. In order to encrypt any text or file , first it is necessary to generate a particular key that will be used for encryption.This key is generated based on password. The parameter used is "PBEWithMD5andDES". Then generally a 8 bit salt is created from it. This salt must be written to the file first as it will be required for decryption of the file later. Next we have to create a Cipher object with the particular mode of encryption as its parameter. Then the Cipher object is initialized with the key and either ENCRYPT_MODE or DECRYPT_MODE . After all this is done, we just need to read a stream of bytes from a particular file using FileInputStream and encrypt it and then write to another file using FileOutputStream.
NOTE : The same key must be used for encrypting and decrypting the same file.
Code Extracts :
PBEKeySpec keySpec = new PBEKeySpec(password.toCharArray());
SecretKeyFactory keyFactory=SecretKeyFactory.getInstance("PBEWithMD5AndDES");
SecretKey passwordKey = keyFactory.generateSecret(keySpec); //key from password
byte[] salt = new byte[8];
Random rnd = new Random();
rnd.nextBytes(salt); //getting salt
int iterations = 100;
PBEParameterSpec parameterSpec = new PBEParameterSpec(salt, iterations);
Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES"); //cipher instance
cipher.init(Cipher.ENCRYPT_MODE, passwordKey, parameterSpec); //initializing instance

Click to DOWNLOAD the JAVA file of password based encrypter from 4shared.com
Click to DOWNLOAD the JAVA file of password based decrypter from 4shared.com

Saturday 24 December 2011

C program to create a 15 puzzle game

This game is a very simple one just a replica of the GUI version developed through Java programming. This game works with keys "w","a","s","d" for moving the blank box up, left, down, right respectively.


Click to DOWNLOAD the C source file from 4shared.com

Java program to encrypt or decrypt a file in DES mode

Java can be very efficiently in encrypting files in DES mode. In order to encrypt any text or file , first it is necessary to generate a particular key that will be used for encryption. Next we have to create a Cipher object with the particular mode of encryption as its parameter. Then the Cipher object is initialized with the key and either ENCRYPT_MODE or DECRYPT_MODE . After all this is done, we just need to read a stream of bytes from a particular file using FileInputStream and encrypt it and then write to another file using FileOutputStream.
NOTE : The same key must be used for encrypting and decrypting the same file.
Code Extracts :
byte key[] = "klHGtyCD".getBytes(); //setting my own key
SecretKeySpec secretKey = new SecretKeySpec(key,"DES"); //key generated
Cipher encrypt=Cipher.getInstance("DES/ECB/PKCS5Padding"); //cipher object
encrypt.init(Cipher.ENCRYPT_MODE, secretKey); //initializing object


Click to DOWNLOAD the JAVA file of Encrypter from 4shared.com
Click to DOWNLOAD the JAVA file of Decrypter from 4shared.com

Thursday 22 December 2011

Java Program to perform Radix Sort

Radix Sort is a type of bucket sort. This type of sort is based on radix i.e. 10 for decimal numbers and 26 for alphabets. This technique is very useful in sorting words alphabetically. Arrays are sorted in a total of "d" passes where "d" is the number of digits of highest number..
For decimal numbers : In first pass array is sorted according to units digit , then in next pass sorted according to tens digit and so on.This process goes on till all the digits of highest numbers are traversed.
For words : In first pass array is sorted according to first letter , and in second pass second character is considered and so on.
Here is the code for you -->

import java.io.*;
public class Radix_Sort {

    public void sort(int a[],int rad,int max){
        int tmp[][]=new int[a.length][10];

        for(int i=0;i<max;i++){

            int c=0;
            for (int j=0;j<a.length;j++)
                for(int k=0;k<rad;k++)
                    tmp[j][k]=0;

            for(int k=0;k<a.length;k++){
                int d=(int)((a[k]/Math.pow(10,i))%10);
                tmp[k][d]=a[k];
            }

            for (int j=0;j<rad;j++)
                for(int k=0;k<a.length;k++)
                    if(tmp[k][j]!=0)
                        a[c++]=tmp[k][j];
        }

        disp(a);
    }

    public void input()throws Exception{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Enter array size : ");
        int n=Integer.parseInt(br.readLine());
        int a[]=new int[n];
        System.out.println("Enter elements in array ------->");
        int max=0;
        for (int i = 0; i<n; i++) {
            System.out.print("Enter number : ");
            a[i]=Integer.parseInt(br.readLine());
            if(a[i]>max)
                max=a[i];
        }
        sort(a,10,digit_count(max));
     }

    int digit_count(int n){
        int d=0;
        while (n!=0) {
            d++;
            n/=10;
        }
        return d;
    }

    public void disp(int a[]){
        System.out.println("\nArray after sorting -------->");
        for (int i = 0; i<a.length; i++)
            System.out.print(a[i]+"  ");
    }

    public static void main(String[] args) throws Exception{
        new Radix_Sort().input();
    }
}


You can also download the source from below links :
DOWNLOAD source JAVA file from MediaFire
DOWNLOAD the JAVA file from 4shared

Wednesday 7 December 2011

New Planet Kepler 22B - Earth Like Discovered

NASA has discovered a Earth like planet named Kepler 22B in our Universe. The Kepler mission was started in the year 2007 and will end in 2012. During this period NASA has come across many stars and planets. From this some were seperated and were similar to our planet and were called candidates. Among this Kepler 22B is one which is almost like Earth's twin revolving around a star like our Sun. It is about 600 light years away from our planet. Kepler 22B is at a 15% distance less than what our Earth is from Sun. The average temperature is about 22C . This planet also has liquid water. Considering all this facts scientists has claimed that this is an ideal planet for habitat. But they are not yet sure whether it is a gaseous or a rocky planet. They are investigating on existence of life which has been yhe question of almost every scientists when Earth is facing its end due to human actions.

Click here to know more news from NASA