Digital Signature Algorithm Java version or on the code bar
public static final String sign_algorithms = "Sha1withrsa"; /** * RSA Signature * @param content pending Signature data * @param privatekey private key * @param input_charset encoded format * @return Signature value */Publi c static string sign (string content, String Privatekey, String input_charset) {try {byte[] de Code =base64.getdecoder (). Decode (Privatekey); Pkcs8encodedkeyspec priPKCS8 = new Pkcs8encodedkeyspec (decode); Keyfactory keyf= keyfactory.getinstance ("RSA"); Privatekey prikey= keyf.generateprivate (priPKCS8); Java.security.Signature Signature = java.security.Signature.getInstance (SIGN_ALGORITHMS); Signature.initsign (Prikey); Signature.update (Content.getbytes (Input_charset)); Byte[] signed = Signature.sign (); Return Base64.getencoder (). encodetostring (Signed); } catch (Exception e) {e.printstacktrace (); } return null; }
Call Mode:
String sign = sign ("Content", "Privatekey", "utf-8");
Over,tks.
RSA Digital Signature Algorithm (Java edition)