Welcome to Srini's blog

Thursday, December 31, 2009

Encrypt in JAVA and Decrypt in PHP & Encrypt in PHP and Decrypt in JAVA

Encrypt in JAVA and decrypt in PHP:

1. Encryption in JAVA:
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;

public class Crypto {
//iv length should be 16 bytes
private String iv = "fedcba9876543210";
private String key = null;
private Cipher cipher = null;
private SecretKeySpec keySpec = null;
private IvParameterSpec ivSpec = null;

/**
* Constructor
*
* @throws Exception
*/
public Crypto(String key) throws Exception {
this.key = key;

// Make sure the key length should be 16
int len = this.key.length();
if(len < 16) {
int addSpaces = 16 - len;
for (int i = 0; i < addSpaces; i++) {
this.key = this.key + " ";
}
} else {
this.key = this.key.substring(0, 16);
}
this.keySpec = new SecretKeySpec(this.key.getBytes(), "AES");
this.ivSpec = new IvParameterSpec(iv.getBytes());
this.cipher = Cipher.getInstance("AES/CBC/NoPadding");
}

/**
* Bytes to Hexa conversion
*
* @param data
* @return
*/
public String bytesToHex(byte[] data) {
if (data == null) {
return null;
} else {
int len = data.length;
String str = "";
for (int i = 0; i < len; i++) {
if ((data[i] & 0xFF) < 16)
str = str + "0" + java.lang.Integer.toHexString(data[i] & 0xFF);
else
str = str + java.lang.Integer.toHexString(data[i] & 0xFF);
}
return str;
}
}

/** Encrpt the goven string
*
* @param plainData
* @throws Exception
*/
public String encrypt(String plainData) throws Exception {

// Make sure the plainData length should be multiple with 16
int len = plainData.length();
int q = len / 16;
int addSpaces = ((q + 1) * 16) - len;
for (int i = 0; i < addSpaces; i++) {
plainData = plainData + " ";
}

this.cipher.init(Cipher.ENCRYPT_MODE, this.keySpec, this.ivSpec);
byte[] encrypted = cipher.doFinal(plainData.getBytes());

return bytesToHex(encrypted);
}

public static void main(String[] args) throws Exception {
Crypto c = new Crypto("D4:6E:AC:3F:F0:BE");
String encrStr = c.encrypt("Hello World");
System.out.println("Encrypted Str :" + encrStr);
}
}
2. After run this program we will get encrypted str, Now decrypt this str using PHP
3. Decryption in PHP
$cipher = "rijndael-128";
$mode = "cbc";
$secret_key = "D4:6E:AC:3F:F0:BE";
//iv length should be 16 bytes
$iv = "fedcba9876543210";

// Make sure the key length should be 16 bytes
$key_len = strlen($secret_key);
if($key_len < 16 ){
$addS = 16 - $key_len;
for($i =0 ;$i < $addS; $i++){
$secret_key.=" ";
}
}else{
$secret_key = substr($secret_key, 0, 16);
}

$td = mcrypt_module_open($cipher, "", $mode, $iv);
mcrypt_generic_init($td, $secret_key, $iv);
$decrypted_text = mdecrypt_generic($td, hex2bin("444e6969a269829a3e59a86300614fc5"));
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
echo trim($decrypted_text);

function hex2bin($hexdata) {
$bindata="";
for ($i=0;$i $bindata.=chr(hexdec(substr($hexdata,$i,2)));
}
return $bindata;
}
?>
4. You will get decrypted str as "Hello World".



Encrypt in PHP and decrypt in JAVA:

1. Encryption in PHP:
$cipher = "rijndael-128";
$mode = "cbc";
$secret_key = "D4:6E:AC:3F:F0:BE";
//iv length should be 16 bytes
$iv = "fedcba9876543210";

// Make sure the key length should be 16 bytes
$key_len = strlen($secret_key);
if($key_len < 16 ){
$addS = 16 - $key_len;
for($i =0 ;$i < $addS; $i++){
$secret_key.=" ";
}
}else{
$secret_key = substr($secret_key, 0, 16);
}

$td = mcrypt_module_open($cipher, "", $mode, $iv);
mcrypt_generic_init($td, $secret_key, $iv);
$cyper_text = mcrypt_generic($td, "Hello World");
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
echo bin2hex($cyper_text);
?>
2. After run this program we will get encrypted str, Now decrypt this str using JAVA
3. Decryption in JAVA

import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;

public class Crypto {
//iv length should be 16 bytes
private String iv = "fedcba9876543210";
private String key = null;
private Cipher cipher = null;
private SecretKeySpec keySpec = null;
private IvParameterSpec ivSpec = null;

/**
* Constructor
*
* @throws Exception
*/
public Crypto(String key) throws Exception {
this.key = key;

// Make sure the key length should be 16
int len = this.key.length();
if(len < 16) {
int addSpaces = 16 - len;
for (int i = 0; i < addSpaces; i++) {
this.key = this.key + " ";
}
} else {
this.key = this.key.substring(0, 16);
}
this.keySpec = new SecretKeySpec(this.key.getBytes(), "AES");
this.ivSpec = new IvParameterSpec(iv.getBytes());
this.cipher = Cipher.getInstance("AES/CBC/NoPadding");
}

/**
* Hexa to Bytes conversion
*
* @param str
* @return
*/
public byte[] hexToBytes(String str) {
if (str == null) {
return null;
} else if (str.length() < 2) {
return null;
} else {
int len = str.length() / 2;
byte[] buffer = new byte[len];
for (int i = 0; i < len; i++) {
buffer[i] = (byte) Integer.parseInt(str.substring(i * 2, i * 2 + 2), 16);
}
return buffer;
}
}

/** Decrypt the given excrypted string
*
* @param encrStr
* @throws Exception
*/
public String decrypt(String encrData) throws Exception {
this.cipher.init(Cipher.DECRYPT_MODE, this.keySpec, this.ivSpec);
byte[] outText = this.cipher.doFinal(hexToBytes(encrData));

String decrData = new String(outText).trim();
return decrData;
}
public static void main(String[] args) throws Exception {
Crypto c = new Crypto("D4:6E:AC:3F:F0:BE");
String decrStr = c.decrypt("444e6969a269829a3e59a86300614fc5");
System.out.println("Decrypted Str :" + decrStr);
}
}
4. You will get decrypted str as "Hello World".

Tuesday, December 1, 2009

How to install native tomcat in LINUX

Steps to install native Tomcat in Linux :
1. First download latest native tomcat(tomcat-native-1.1.18-src.tar.gz) src from http://www.apache.org/dist/tomcat/tomcat-connectors/native/1.1.18/source/
2. Create temp location(eg. /tmp/tomcat) and copy downloded src into this folder
3. Run the following cmd to untar --> tar -xzvf tomcat-native-1.1.18-src.tar.gz
4. go to /tomcat-native-1.1.18-src/jni/native and run the cmd --> ./configure && make
5. It may propmt you an error as "apr is not located" and suggest give the cmd as --with-apr=APRDIR
The error because of apr is not installed in system. So now Install latest apr
Steps to Install apr :
6. Download latest apr(apr-1.3.9.tar.gz) src from
http://apache.opensourceresources.org/apr/
7. copy apr src into temp location(/tmp/tomcat).
8. Run the following cmd to untar --> tar -xzvf apr-1.3.9.tar.gz
9. Go to /apr-1.3.9 and run the cmd --> ./configure && make && make install.
So, apr installation completed. Now try to install native tomcat
10. go to /tomcat-native-1.1.18-src/jni/native and run the cmd --> ./configure && make
11. It may prompt you an error as "JDK is not located".
The error because of jdk is not installed in system(we need JDK to compile native
tomcat).So install latest JDK
Steps to install JDK :
12. Download latest JDK(jdk-6u17-linux-i586.bin) from http://java.sun.com/javase/downloads/index.jsp
13. Copy downloaded JDk into /usr/java(If location is not existed, create it and copy it).
14. Go to /usr/java and give permissions to jdk-6u17-linux-i586.bin file --> chmod 755 jdk-6u17-linux-i586.bin
15. install JDK using cmd --> ./jdk-6u17-linux-i586.bin
16. Follow the instructions carefully and install JDK.
17. If JDK installed successfully u can see 'jdk1.6.0_17' folder in /usr/java/.
18. Set java home path using cmds
i. JAVA_HOME="/usr/java/jdk1.6.0_17/"
ii. export JAVA_HOME.
So, JDK installation completed. Now try to install native tomcat.
19. go to /tomcat-native-1.1.18-src/jni/native and run the cmd --> ./configure && make.
20.Native tomcat installation completed successfully.

If you have any doubts/clarifications please let me know.

Thursday, November 5, 2009

What is Skype ?

Skype is software that enables the world’s conversations. Millions of individuals and businesses use Skype to make free video and voice calls, send instant messages and share files with other Skype users. Everyday, people everywhere also use Skype to make low-cost calls to landlines and mobiles. For more details Click Here

Skype is available for:
· Windows
· Mac OSX
· iPhone
· Linux
· Mobile phones
· WiFi and Cordless phones
· Playstation ® Portable
· MIDs
· Nokia Internet Tablet.

New features introduced in version 4.1

1. Screen sharing -- Share your screen with other Skype users.
2. Accessibility -- Keyboard navigation and MSAA support.
3. Contact Importers -- Allows you to import more contacts from external address books.
4. Birthday reminders -- Alerts you when one of your contacts has a birthday.
5. Send Contacts -- Skype browser toolbar improvements.
6. Password rules -- Improved password rules for better security.

.... and lot more improvements ...

Download skype

How to Import/Export Favorites & Bookmarks in IE & Firefox

Export Favorites in IE 7 :

1. In Internet Explorer, click Add to Favorites, and then click Import and Export.
2. In the Import/Export Wizard, click Next.
3. Select Export Favorites, and then click Next.
4. Click Favorites and then click Next.
5. Select the Favorites folder that you want to export. If you want to export all Favorites, select the top level Favorites folder. Otherwise, select the individual folder that you want to export.
6. Click Next.

Note By default, Internet Explorer creates a Bookmark.htm file in your Documents folder. If you want to use a name other than Bookmark.htm, or if you want to store the exported Favorites in a folder other than the Documents folder, specify the new file and folder name.
7. Click Next.
8. Click Finish.

Export Favorites in IE 8 :

1. In Internet Explorer, click Favorites, click the down-arrow next to Add to Favorites, and then click Import and Export.
2. Click Export to a file, and then click Next.
3. Click to select the Favorites check box, and then click Next.
4. Select the Favorites folder that you want to export. If you want to export all Favorites, select the top level Favorites folder. Otherwise, select the individual folder that you want to export.
5. Click Next.

Note By default, Internet Explorer creates a Bookmark.htm file in your Documents folder. If you want to use a name other than Bookmark.htm, or if you want to store the exported Favorites in a folder other than the Documents folder, specify the new file and folder name.
6. Click Next.
7. Click Export.
8. Click Finish.

Import Favorites in IE 7:

1. In Internet Explorer 7, click Add to Favorites , and then click Import and Export.
2. In the Import/Export Wizard, click Next.
3. Select Import Favorites, and then click Next.

Note By default, Internet Explorer creates a Bookmark.htm file in your Documents folder. However, you can import favorites that are saved under another name. To do this, click Browse, select a file or type a location and file name, and then click Next. Or, click Browse, and then click Next to accept the default.
4. Select the folder where you want to put the imported bookmarks, and then click Next.
5. Click Finish.

Import Favorites in IE 8:

1. In Internet Explorer, click Favorites, click the down-arrow next to Add to Favorites, and then click Import and Export.
2. Click Import from a file, and then click Next.
3. Click to select the Favorites check box, and then click Next.
4. By default, Internet Explorer creates a Bookmark.htm file in your Documents folder. However, you can import favorites that are saved under another name. To do this, click Browse, select a file or type a location and file name, and then click Next.
5. Select the folder where you want to put the imported bookmarks, and then click Import.
6. Click Finish.


Export bookmarks in Mozilla firefox :

1. In Firefox, click bookmarks menu and click Organize Bookmarks.
2. Select bookmark which you want to export by default all folders select.
3. Click Import and Backup in menu bar and select Export HTML.
4. Give name to bookmarks and Save it.

Import bookmarks in Mozilla firefox :

1. In Firefox, click bookmarks menu and click Organize Bookmarks.
3. Click Import and Backup in menu bar and select Import HTML.
4. It will prompt you import wizard to select import from.
5. Select one and click Next.
6. Select the bookmark file and Save it.

Monday, September 14, 2009

Tirupati Tour

We are planning to visit Tirupati from last 1 year, but plan was not executed with some reasons, At last we did that in last weekend(12th Spet 2009).
15 days before we went to TTD and fixed darshanam date and time with sudarshan token(50Rs/person and need person to take token).
On 11th Sept I had started from hyd in venkatadri Exp and reached Tirupati on next-day morning 7 A.M, On the other side naidu started from chennai and reached Tirupati on 3 A.M and booked room for us in Sreenivasm(near RTC bustand). 400 Rs/day(of-course its costly but no way to escape).I reached sreenivasm at 8 A.M from railway station and had brush and bath, Naidu already ready and waiting for me. Facilities in the room are not bad.

We left from Sreenivasm at 9 A.M and catch the local bus to reach ALIPIRI(We decided to goto up hill thru walk... its 4 km from Sreenivasm).We started walking at 10 A.M, there are so many pilgrims with us by walk. The total distance to reach up hill thru walk is apporx 17Km(3500 steps and some road way). We enjoyed the walking a lot with some snapshots and discussions with co-pilgrims .At one point we stopped walking (of-course this is not the first breaking pt... !!)for breakfast and had DOSA(extremely super taste) and again started walking with my nasty and funny jokes . After 9 months this is the time we met each other and shared all funny matters turned in our day-to-day life from last 9 months and some personal stuff also...!! We discussed lot of things on the way, So we did not feel like tired.
We reached Tirumal at 1.54 P.M and searched for sudarshan token darshanam queue, before that we kept mobiles and cam in free safety lockers and went to sudarshan token darshan block. We did not feel while walking long way , but we are really frustrated to keep mobiles in safety lockers(almost we spent 2 hrs in queue . really horrible).Almost 2 hrs in queue we got darshanam and collected free laddus. Then we went to free meals (Sambar is very tasty ..!!) and return to Sreenivasm by bus(24Rs. tkt). We stayed that night at sreenivasm .
Next day early morning we waked up at 5.30 A.M and decided to visit "sreekalahasti" 30K.M far from Tirupati. We started at 8 A.M on bus and reached kalahasti at 8.45 A.M and completed darshanam at around 10 A.M and returned back to Tirupati. After that We visited "Govindarajulu swami" temple which is 3 K.M far from Tirupati bus stand and returned back to home.

Here are some snapshots

Suggestions to who are willing to visit Tirupati.

1. First book the sudarshan token(50Rs/person)at TTD e-darsan counters with date and time before 15days back(If you want room plz book 1 month before).
2. If you want to go to Tirumala thru walk better to book one room at Sreenivasm(200Rs/day) to fresh up thr and start walk.
3. Otherwise better to book room at Tirumala(on the hill ... 100Rs/day).
4. Surrounding places to visit in Tirupati
a. Govindaraju swami temple(3km far from bus station)
b. Padmavati amma temple(7 km far from bus station).

Wednesday, September 2, 2009

EAMCET 2009 seat allotment postponed

According to news EAMCET-2009 seat allotment procedure postponed to 3rd sept 2009.Seat allotment info is send as SMS to mobile number. We can also get info on website http://apeamcet.nic.in/ .

Monday, August 31, 2009

Swine Flu Symptoms and Precautions

About Swine Flu
Swine flu is a Type A influenza virus which causes regular outbreaks of flu in pigs.In late April 2009, the outbreak of more than a thousand cases of swine flu in humans.

Symptoms of Swine Flu
The symptoms of swine flu are usually like those of regular seasonal flu and include:

* headache
* chills
* cough
* fever
* loss of appetite
* aches
* fatigue
* runny nose
* sneezing
* watery eyes
* throat irritation
* nausea and vomiting
* diarrhea
* in people with chronic conditions, pneumonia may develop

Precautions Against Swine Flu
Good standard flu prevention techniques are recommended to protect yourself against swine flu:
* Get a regular seasonal flu vaccination. It might not help against this specific strain, but it won't hurt.
* Wash your hands frequently with soap and hot running water. If hot water is not available, use an alcohol-based hand gel.
* When you cough and sneeze, cover your mouth and nose. Wash your hands afterwards.
* Avoid being near others who might be sick.
* Stay home if you are sick, to avoid affecting others.

Precautions for Travellers
* Before you travel, find out what vaccines you will need and where to get them. Visit your family doctor or a travel health clinic at least six weeks before your departure date.
* If you get sick when you are travelling, seek medical assistance.
* If you are sick when you return to Canada, or have been near someone who is, you must tell a customs or quarantine office, who will decide if you need further medical assessment.
* If you get sick after you return to Canada, see a health care provider. Be sure to tell him/her the countries you visited, if you were sick while away and any medical care or treatment your received.

EAMCET 2009 seat allotments

The allotment of seat will be done on 31st of August. To know your allotment of seats visit the same website where you’ve put your options and enter the registration number, hall ticket number, password and date of birth.

After you log in you can see the seat and college that was allotted to you which you have to download immediately along with the challan to pay the fee. Challan will also be available in the website itself.

The counselling fee is Rs.500 (Rs.300 for SC/ST students) and the tution fee is Rs.10000 per year for a University seat and Rs.30200 per year for a Self-financed Universities or Private institutions.However, no such tution fee is required to be paid by students whose parents’ annual income is less than Rs.1 lakh.

The required amount of fee has to be paid in any branch of Andhra bank or Indian bank in Andhra Pradesh and a receipt has to be taken.

Once every thing is done, you have to report to the college in which the seat was allotted along with the receipt of certificates verification, fee receipt and allotment order before the time mentioned in the allotment order failing which the seat may stand cancelled.

The classes for Engineering are scheduled to begin from September 7th. The second counseling for Engineering will start from September 20 till 25th. The allocation of seats for which will be done on September 30.

Monday, July 27, 2009

How to submit a site/blog to google indexer

To add your site/blog to Google, Go to google webmasters and sign in with your Google Account. Copy and paste the URL of your site/blog into the text box at the top for "Add Site" and click OK. Google adds the site and the next page opens on which click "Verify your Site". On the next page clickdown arrow besides "Choose Verification Method". Here select " Add a Meta Tag" and a metatag is generated for you. Copy and paste this metatag into your template just below the 'title' tags.

How to add metatag into your blog home page ??
Go to your blog home page --> Layout --> Edit HTML --> Edit Template --> add copied metatag with in the 'head' tag and save changes.Now test it.

Note : you can add site and remove exiting site from google indexing.
If you have any doubts/clarifications let me know, so that i can help you on regarding this.

Arihant launched at Visakhapatnam

India’s first indigenously built nuclear propelled strategic submarine named ‘Arihant’ meaning ‘Destroyer of the Enemies’ was launched yesterday, 26 Jul 09, at the Ship Building Center, Visakhapatnam. India has thus joined a select group of nations which have the technological capability to build and operate nuclear propelled submarines.

More Details : Arihant Wiki

Magadheera Release date confirmed

It has been quite a while since the entire chiru's fans have been waiting anxiously for the release of the new movie ‘Magadheera’.

While most of them thought that the release was happening on the 29th of July, the latest news is it is confirmed that the release date has been postponed to July 31st 2009.

So guys get ready to watch Tollywood blockbuster movie of the year 2009.

Magadheera Movie Gallery

Google Chrome OS

Google already launched google chrome browser, Now ready to launch google chrome OS.
Google Chrome OS is an open source, lightweight operating system that will initially be targeted at netbooks.
For more details : Official google blog

EAMCET- 2009 Web counselling Details

Engineering Agriculture and Medicine Common Entrance Test is conducted by JNT University on behalf of APSCHE. This examination is the gateway for entry into various professional courses offered in Government/Private Colleges in Andhra Pradesh. This site provides important information and links.

Local rank Info
Revised ranks of Engineering Candidates
Revised ranks of Agriculture & Medicine Candidates

For more details : Click Here

Monday, June 29, 2009

ECET 2009 counselling Dates and Fee details

Here are the ECET Counseling Details
Please. carry the Originals of following certificates:

a. ECET 2009 rank card, hall ticket
b. diploma/degree (provisional) & and marks sheets of qualifying exam
c. Date of birth, study certificates from 7th standard onwards
d. residence proof
e. community certificate for reservation
f. income certificate of parents
g. quota certificate for sports/ncc etc

1. For B.Sc. Graduates who are ECET 2009 Qualified Counseling is on 27-Jun-2009 at 09:00AM at Sanketika Vidya Bhavan, Masab Tank, Hyderabad

2. For Diploma Holders who are ECET 2009 Qualified in the branches of EIE, CHE, MET, MIN, CER Counseling is on 28-Jun-2009 at Sanketika Vidya Bhavan, Masab Tank, Hyderabad. (EIE will be at 9AM, CHE will be at 1 PM and all others at 2 PM)

3. For Diploma Holderswho are ECET 2009 Qualified in the branches of CIV, CSE, EEE, ECE, MEC, PHM, INF: The admissions are De-Centralized. The admissions will happen at the Government Polytechnic Colleges at: Guntur, Vijayawada, Visakhapatnam, Secunderabad, Hyderabad, Warangal, Tirupati and Kadapa.

The schedule is as follows:
CIV: Rank 1 to 700 -- 29-Jun, 9AM
CIV: Rank 700 to END -- 29-Jun, 1 PM
CSE: Rank 1 to 800 -- 30-Jun, 9AM
CSE: Rank 800 to LAST -- 30-Jun, 1 PM
EEE: All Girls -- 01-Jul, 9AM
EEE: Rank 1 to 500 -- 01-Jul, 10AM
EEE: Rank 501 to 1000 -- 01-Jul, 1PM
EEE: Rank 1001 to 2000 -- 02-Jul, 9AM
EEE: Rank 2000 to END -- 01-Jul, 1PM
ECE: Rank 1 to 900 -- 3-Jul, 9AM
ECE: Rank 901 to 1800 -- 3-Jul, 1PM
ECE: Rank 1801 to 2700 -- 4-Jul, 9AM
ECE: Rank 2701 to END -- 4-Jul, 1PM
BME: Rank 1 to END -- 5-Jul, 9AM
MEC: All Girls -- 6-Jul, 9AM
MEC: Rank 1 to 500 -- 6-Jul, 10AM
MEC: Rank 501 to 1000 -- 6-Jul, 1PM
MEC: Rank 1001 to 1800 -- 7-Jul, 9AM
MEC: Rank 1801 to END -- 7-Jul, 1PM
PHM: Rank 1 to 1000 -- 8-Jul, 9AM
PHM: Rank 1001 to END -- 8-Jul, 1PM
INF: Rank 1 to 6000 -- 9-Jul, 9AM
INF: Rank 6001 to END -- 9-Jul, 1PM

4. For Diploma Holders who are ECET 2009 Qualified and are seeking admissions through Sports, Children of Armed Forces Quota Counseling is on 10-Jul-2009 at 08:30AM at Sanketika Vidya Bhavan, Masab Tank, Hyderabad.

5. For Diploma Holders who are ECET 2009 Qualified and are seeking admissions through NCC, Physically Handicapped Quota Counseling is on 11-Jul-2009 at 08:30AM at Sanketika Vidya Bhavan, Masab Tank, Hyderabad.
The counseling for ECET 2009, for direct admissions to 2nd year Engineering courses in Andhra Pradesh will start from 24 Jun 2009. The Counseling will continue till 3-Jul-2009. ECET Admissions will be conducted in person by JNTU Candidates have to appear for the counseling session along with all relevant certificates.
More updates soon…

Fee details for BC category students :
According to latest info there is no fee for who belonging to BC category .
Today My friend's brother appeared for ECET(CIVIL) counsaling at Vijayawada,he was BC category student. He told me that no fee for BC students but make sure to have catse certificate.

Sunday, June 28, 2009

First posting in my blog

Hi
I am srinivas from hyderabad. This is first posting in my blog .

Thanks,
T Srinivas.