Custom Search

Thursday, September 18, 2008

video clip Jquery Smooth Scrolling

video clip Jquery Smooth Scrolling

video clip jQuery using the slide effects

video clip jQuery using the slide effects


video clip jquery tutorial

video clip jquery tutorial


video clip jquery tutorial part 1



video clip jquery tutorial part 2

Wednesday, July 2, 2008

Eclipse and Java for Total Beginners

Eclipse and Java for Total Beginners

วันนี้พอดีไปเจอ video วิธีการเขียนโปรแกรมจาวา โดยใช้ Eclipse เห็นมันน่าสนใจดี ลองศึกษาดูแล้วกันนะครับสำหรับผู้เริ่มต้น

Friday, June 27, 2008

JAVA Sample Cryptography - Triple DES Encryption

วันนี้เอาตัวอย่างการเข้ารหัสมาฝากครับ ลองดูนะครับ
สามารถ copy ไปใช้กันได้เลยนะครับ

import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.KeySpec;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class TripDESEncrypter {

private static final String PBEWITH_MD5AND_DES = "PBEWithMD5AndDES";
private static final String DEFAULT_ENCODE = "UTF-8";
private static final String SECRET_STRING = "SECRET KEY";

private Cipher ecipher;
private Cipher dcipher;

public TripDESEncrypter(){
try{
byte[] salt = {
(byte)0xA9, (byte)0x9B, (byte)0xC8, (byte)0x32,
(byte)0x56, (byte)0x34, (byte)0xE3, (byte)0x03
};

int iterationCount = 19;

KeySpec keySpec = new PBEKeySpec(SECRET_STRING.toCharArray(), salt, iterationCount);
SecretKey key = SecretKeyFactory.getInstance(PBEWITH_MD5AND_DES).generateSecret(keySpec);

ecipher = Cipher.getInstance(key.getAlgorithm());
dcipher = Cipher.getInstance(key.getAlgorithm());

AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);

ecipher.init(Cipher.ENCRYPT_MODE, key , paramSpec);
dcipher.init(Cipher.DECRYPT_MODE, key , paramSpec);


}catch(Exception e){
e.printStackTrace();
}
}

private String encryptData(String s,String encode){
try{
byte[] b = s.getBytes(encode);
byte[] enc = ecipher.doFinal(b);
return new BASE64Encoder().encode(enc);
}catch(Exception e){
e.printStackTrace();
}
return null;
}

private String decryptData(String s,String encode){
try{
byte[] dec = new BASE64Decoder().decodeBuffer(s);
byte[] b = dcipher.doFinal(dec);
return new String(b,encode);
}catch(Exception e){
e.printStackTrace();
}
return null;
}
public String encrypt(String s){

return encryptData(s,DEFAULT_ENCODE);
}

public String encrypt(String s,String encode){

return encryptData(s,encode);
}

public String decrypt(String s){
return decryptData(s,DEFAULT_ENCODE);
}

public String decrypt(String s,String encode){
return decryptData(s,encode);
}
}

Thursday, June 26, 2008

JSP: บทบาทที่แอบแฝงของ Cookie และ ตัวอย่างการใช้งาน




บทบาทที่แอบแฝงของ Cookie
Cookie เป็นเทคนิคอีกอย่างหนึงที่ website ชั้นนำนิยมใช้กัน เพราะเป็น file ที่ช่วยเก็บข้อมูลสำคัญไว้ในเครื่อง computer ของผู้ชมทางฝัง client และ script ทางฝัง server สามารถอ่านข้อมูลเหล่านั้นมาใช้ประโยชน์ ทุกครั้งที่ผู้ชมคนนั้นแวะเวียนกลับเข้ามายัง website ของเรา

ข้อกำหนดของ Cookie
1) Web browser อนุญาติให้แต่ละเว็บไชต์สร้าง cookie ไว้ในเครื่องของผู้ใช้ ไม่เกิน 20 cookie ต่อ website
2) แต่ละ cookie ไม่สามารถเก็บข้อมูลเกิน 4 kb
3) Cookie ของแต่ละ website จะเก็บรวมกันอยู่ใน text file โดยถายในเครื่อง client จะมี cookie อยู่กี่ file ก็ได้ แต่จำนวน cookie ของทุก file รวมกันจะต้องไม่เกิน 300 cookie ถ้ามีการสร้าง cookie เกินจากนี้ cookie ทีถูกสร้างไว้เป็นลำดับแรกจะถูกลบออกไป

ตัวอย่าง การใช้ cookie ในการบันทึกการ Login ของ user

form.jsp





















login.jsp

















สำคัญ ถ้ามีการ เก็บข้อมูลพวก username และ password ระบบควรมีการเข้ารหัสข้อมูล ก่อนนะครับเพื่อความปลอดภัยของ user
ส่วนเรื่องของการเข้ารหัสข้อมูล ติดตามต่อนต่อไปนะครับ

Monday, May 26, 2008

Getting Peak XML Query Performance

XML Application typically require high-performance levels. And a good part of the responseibility for achieving that performance reset on application designers and DBAs. In his developerWork article "15 Bast Practices for pureXML Performance in DB2" Mattias Nicola explains how to get the bast performance from DB2 9's pureXML technology. His first tips are summarized here; read the full article online at ibm.com/developerworks/db2/library/techarticle/dm-0610nicola.