Pages

2011年9月7日 星期三

使用Triple DES 加密字串

最近因為有需求,需要使用加密的方法來讓連線的帳號密碼用成亂碼來連線。 因此找到了使用 Tripple DES的方式加密字串。 1. 首先,先寄建立Decrypter與Encrypter package security.crypto; import java.io.UnsupportedEncodingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; import javax.crypto.SecretKey; public classDecrypter { Cipher decipher; public Decrypter(SecretKey key) { try { decipher = Cipher.getInstance("DESede"); decipher.init(Cipher.DECRYPT_MODE, key); }...