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

Method toKey

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

转换密钥 @param key 二进制密钥 @return Key 密钥 @throws Exception

(byte[] key)

Source from the content-addressed store, hash-verified

48 * @throws Exception
49 */
50 private static Key toKey(byte[] key) throws InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException {
51
52 // 实例化DES密钥材料
53 DESKeySpec dks = new DESKeySpec(key);
54
55 // 实例化秘密密钥工厂
56 SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(KEY_ALGORITHM);
57
58 // 生成秘密密钥
59 SecretKey secretKey = keyFactory.generateSecret(dks);
60
61 return secretKey;
62 }
63
64 /**
65 * 解密

Callers 2

decryptMethod · 0.95
encryptMethod · 0.95

Calls 1

getInstanceMethod · 0.80

Tested by

no test coverage detected