org.civis.blockchain.ssm.client.crypto.Sha256RSASigner Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ssm-sdk-client Show documentation
Show all versions of ssm-sdk-client Show documentation
A SDK HTTP Client implementation to interact with signing state machines chaincode developped for Hyperleger Fabric.
The newest version!
package org.civis.blockchain.ssm.client.crypto;
import java.security.PrivateKey;
import java.security.Signature;
import java.util.Base64;
public class Sha256RSASigner {
public static byte[] rsaSign(String plainText, PrivateKey key) throws Exception {
Signature privateSignature = Signature.getInstance("SHA256withRSA");
privateSignature.initSign(key);
privateSignature.update(plainText.getBytes("UTF-8"));
return privateSignature.sign();
}
public static String rsaSignAsB64(String plainText, PrivateKey key) throws Exception {
byte[] value = rsaSign(plainText, key);
return b64Encode(value);
}
private static String b64Encode(byte[] value) {
return Base64.getEncoder().encodeToString(value);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy