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

Method encrypt

security/src/main/java/pro/tools/security/ToolDH.java:160–171  ·  view source on GitHub ↗

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

(byte[] data, byte[] key)

Source from the content-addressed store, hash-verified

158 * @throws Exception
159 */
160 public static byte[] encrypt(byte[] data, byte[] key) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
161
162 // 生成本地密钥
163 SecretKey secretKey = new SecretKeySpec(key, SECRET_KEY_ALGORITHM);
164
165 // 数据加密
166 Cipher cipher = Cipher.getInstance(secretKey.getAlgorithm());
167
168 cipher.init(Cipher.ENCRYPT_MODE, secretKey);
169
170 return cipher.doFinal(data);
171 }
172
173 /**
174 * 解密<br>

Callers

nothing calls this directly

Calls 2

getInstanceMethod · 0.80
initMethod · 0.45

Tested by

no test coverage detected