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

Method encrypt

security/src/main/java/pro/tools/security/ToolDES.java:103–116  ·  view source on GitHub ↗

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

(byte[] data, byte[] key)

Source from the content-addressed store, hash-verified

101 * @throws Exception
102 */
103 public static byte[] encrypt(byte[] data, byte[] key) throws NoSuchAlgorithmException, InvalidKeyException, InvalidKeySpecException, NoSuchPaddingException, BadPaddingException, IllegalBlockSizeException {
104
105 // 还原密钥
106 Key k = toKey(key);
107
108 // 实例化
109 Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
110
111 // 初始化,设置为加密模式
112 cipher.init(Cipher.ENCRYPT_MODE, k);
113
114 // 执行操作
115 return cipher.doFinal(data);
116 }
117
118 /**
119 * 生成密钥 <br>

Callers

nothing calls this directly

Calls 3

toKeyMethod · 0.95
getInstanceMethod · 0.80
initMethod · 0.45

Tested by

no test coverage detected