@Test
public void testSign() throws Exception {

    System.out.println("私钥加密——公钥解密");
    String inputStr = "sign";
    byte[] data = inputStr.getBytes();
    byte[] encodedData = RSACoder.encryptByPrivateKey(data, privateKey);
    byte[] decodedData = RSACoder.decryptByPublicKey(encodedData, publicKey);
    String outputStr = new String(decodedData);
    System.out.println("加密前: " + inputStr + "\n\r" + "解密后: " + outputStr);
    assertEquals(inputStr, outputStr);
    System.out.println("私钥签名——公钥验证签名");
    // 产生签名
    String sign = RSACoder.sign(encodedData, privateKey);
    System.out.println("签名:" + sign);
    // 验证签名
    boolean status = RSACoder.verify(encodedData, publicKey, sign);
    System.out.println("状态:" + status);
    assertTrue(status);
}