最近因為有需求,需要使用加密的方法來讓連線的帳號密碼用成亂碼來連線。
因此找到了使用 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);
}...