### Question:
Signature { public String sign(Map<String, String> data) throws Exception { PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(Base64.decodeBase64(privateKey)); PrivateKey privateK = KeyFactory.getInstance("RSA").generatePrivate(pkcs8KeySpec); java.security.Signature signature = java.security.Signature.getInstance("SHA1WithRSA"); signature.initSign(privateK); String stringData = mapToString(data); System.out.println(stringData); signature.update(stringData.getBytes("utf-8")); return Base64.encodeBase64String(signature.sign()); } Signature(String privateKey, String publicKey); String sign(Map<String, String> data); boolean verify(Map<String, String> data);  }### Answer:
@Test public void sign() throws Exception { Signature s = new Signature(privateKey, publicKey); assertThat(s.sign(toSign), is("H02s3NQfgtth5chowfXNrZxjKbJGrI73NJgS5/RXsQJ1ftmctFd3ZSlSw+jHCoWA43p4FsVZfFxSlXq7ZODBag4c26ipfVHd0W9NqLcoxJHZB6fKNDnuQuipgPfiAsy9FuGNA7MpkY+16aqg9UgH9meD9aVM0l0tWqWtjEkuh58=")); }
@Test public void sign2() throws Exception { Signature s = new Signature(privateKey, publicKey); assertThat(s.sign(toSign2), is("cAROb4OBHuvcizCVLq1acBfKAvZj9MstgJOrATtgCfpKGyS/MfEL+m4X4FM/MJL8nFZA7k1qG3H9HUHbbTqFcowGlz3pO3KtF7gccVDY5GvYvzRx47PfgnTX7nE2lkLJV9jIG3rg3ylfIA3cuA9x3eq++HfainC3nuZwjxtsar4=")); }