· 7 years ago · Oct 09, 2018, 03:02 AM
1public byte[] EncryptSecretKey(SecretKey secretKey) {
2 Cipher cipher = null;
3 byte[] key = null;
4 try {
5 cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
6 cipher.init(Cipher.ENCRYPT_MODE, publicKey);
7 key = cipher.doFinal(secretKey.getEncoded());
8 } catch (Exception e) {
9 e.printStackTrace();
10 }
11 return key;
12}