?? rsacryptography.java
字號(hào):
/**
* RSA加密解碼相關(guān)類
*/
package src;
import java.security.*;
import javax.crypto.*;
public class RSACryptography {
Cipher cipher;
public RSACryptography() {
try {
cipher = Cipher.getInstance("RSA");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
}
}
public byte[] encrypt_decrypt(byte[] byteInput, Key key, boolean crypto) {
try {
if(crypto){
cipher.init(Cipher.ENCRYPT_MODE,key);
}else{
cipher.init(Cipher.DECRYPT_MODE,key);
}
byte[] cipherByte = cipher.doFinal(byteInput);
return cipherByte;
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
}
return null;
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -