MCPcopy Create free account
hub / github.com/FongMi/TV / generateKey

Method generateKey

quickjs/src/main/java/com/fongmi/quickjs/utils/Crypto.java:64–68  ·  view source on GitHub ↗
(boolean pub, String key)

Source from the content-addressed store, hash-verified

62 }
63
64 private static Key generateKey(boolean pub, String key) throws Exception {
65 if (pub) key = key.replaceAll("[\\r\\n]", "").replace("-----BEGIN PUBLIC KEY-----", "").replace("-----END PUBLIC KEY-----", "");
66 else key = key.replaceAll("[\\r\\n]", "").replace("-----BEGIN PRIVATE KEY-----", "").replace("-----END PRIVATE KEY-----", "");
67 return pub ? KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(Base64.decode(key, Base64.DEFAULT))) : KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(Base64.decode(key, Base64.DEFAULT)));
68 }
69}

Callers 1

rsaMethod · 0.95

Calls 3

getInstanceMethod · 0.80
decodeMethod · 0.80
replaceMethod · 0.45

Tested by

no test coverage detected