MCPcopy Create free account
hub / github.com/SeanDragon/protools / decrypt

Method decrypt

security/src/main/java/pro/tools/security/ToolAES.java:78–92  ·  view source on GitHub ↗

解密 @param data 待解密数据 @param key 密钥 @return byte[] 解密数据 @throws Exception

(byte[] data, byte[] key)

Source from the content-addressed store, hash-verified

76 * @throws Exception
77 */
78 public static byte[] decrypt(byte[] data, byte[] key) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
79 // 还原密钥
80 Key k = toKey(key);
81
82 /*
83 * 实例化 使用PKCS7Padding填充方式,按如下方式实现 Cipher.getInstance(CIPHER_ALGORITHM, "BC");
84 */
85 Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
86
87 // 初始化,设置为解密模式
88 cipher.init(Cipher.DECRYPT_MODE, k);
89
90 // 执行操作
91 return cipher.doFinal(data);
92 }
93
94 /**
95 * 加密

Callers

nothing calls this directly

Calls 3

toKeyMethod · 0.95
getInstanceMethod · 0.80
initMethod · 0.45

Tested by

no test coverage detected