### Question:
CertificateCoder { public static String sign(byte[] sign, String keyStorePath, String alias, String password) throws Exception { X509Certificate x509Certificate = (X509Certificate) getCertificate( keyStorePath, alias, password); KeyStore ks = getKeyStore(keyStorePath, password); PrivateKey privateKey = (PrivateKey) ks.getKey(alias, password .toCharArray()); Signature signature = Signature.getInstance(x509Certificate .getSigAlgName()); signature.initSign(privateKey); signature.update(sign); return Base64.encodeBase64String(signature.sign()); }  static byte[] encryptByPrivateKey(byte[] data, String keyStorePath,
                                             String alias, String password); static byte[] decryptByPrivateKey(byte[] data, String keyStorePath,
                                             String alias, String password); static byte[] encryptByPublicKey(byte[] data, String certificatePath); static byte[] decryptByPublicKey(byte[] data, String certificatePath); static boolean verifyCertificate(String certificatePath); static boolean verifyCertificate(Date date, String certificatePath); static String sign(byte[] sign, String keyStorePath, String alias,
                              String password); static boolean verifyCertificate(Date date, String keyStorePath,
                                            String alias, String password); static boolean verify(byte[] data, String sign,
                                 String certificatePath); static boolean verifyCertificate(String keyStorePath, String alias,
                                            String password); static final String KEY_STORE; static final String X509; }### Answer:
@Test public void testSign() throws Exception { String inputStr = "签名"; byte[] data = inputStr.getBytes(); System.err.println("私钥签名——公钥验证"); String sign = CertificateCoder .sign(data, keyStorePath, alias, password); System.err.println("签名:\n" + sign); boolean status = CertificateCoder.verify(data, sign, certificatePath); System.err.println("状态:\n" + status); assertTrue(status); }