MCPcopy Index your code
hub / github.com/ccxt/ccxt / rsaSign

Method rsaSign

java/lib/src/main/java/io/github/ccxt/base/Crypto.java:320–339  ·  view source on GitHub ↗
(String data, String pemPrivateKey, String hashAlgo)

Source from the content-addressed store, hash-verified

318 }
319
320 private static byte[] rsaSign(String data, String pemPrivateKey, String hashAlgo) {
321 String jce = switch (hashAlgo) {
322 case "sha1" -> "SHA1withRSA";
323 case "sha256" -> "SHA256withRSA";
324 case "sha384" -> "SHA384withRSA";
325 case "sha512" -> "SHA512withRSA";
326 case "md5" -> "MD5withRSA";
327 default -> throw new IllegalArgumentException("Invalid hash algorithm name: " + hashAlgo);
328 };
329
330 try {
331 PrivateKey key = readRSAPrivateKeyFromPem(pemPrivateKey);
332 Signature sig = Signature.getInstance(jce);
333 sig.initSign(key);
334 sig.update(toUtf8(data));
335 return sig.sign();
336 } catch (Exception e) {
337 throw new RuntimeException(e);
338 }
339 }
340
341
342 private static PrivateKey readRSAPrivateKeyFromPem(String pem) throws Exception {

Callers 2

JwtMethod · 0.95
RsaMethod · 0.95

Calls 4

toUtf8Method · 0.95
updateMethod · 0.45
signMethod · 0.45

Tested by

no test coverage detected