|
@@ -45,16 +45,24 @@ public class WxCryptUtilTest { |
|
|
|
|
|
|
|
|
Element root = document.getDocumentElement();
|
|
|
Element root = document.getDocumentElement();
|
|
|
String cipherText = root.getElementsByTagName("Encrypt").item(0).getTextContent();
|
|
|
String cipherText = root.getElementsByTagName("Encrypt").item(0).getTextContent();
|
|
|
|
|
|
System.out.println(cipherText);
|
|
|
|
|
|
|
|
|
String msgSignature = root.getElementsByTagName("MsgSignature").item(0).getTextContent();
|
|
|
String msgSignature = root.getElementsByTagName("MsgSignature").item(0).getTextContent();
|
|
|
|
|
|
System.out.println(msgSignature);
|
|
|
|
|
|
|
|
|
String timestamp = root.getElementsByTagName("TimeStamp").item(0).getTextContent();
|
|
|
String timestamp = root.getElementsByTagName("TimeStamp").item(0).getTextContent();
|
|
|
|
|
|
System.out.println(timestamp);
|
|
|
|
|
|
|
|
|
String nonce = root.getElementsByTagName("Nonce").item(0).getTextContent();
|
|
|
String nonce = root.getElementsByTagName("Nonce").item(0).getTextContent();
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(nonce);
|
|
|
|
|
|
|
|
|
String messageText = String.format(xmlFormat, cipherText);
|
|
|
String messageText = String.format(xmlFormat, cipherText);
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(messageText);
|
|
|
|
|
|
|
|
|
// 第三方收到企业号平台发送的消息
|
|
|
// 第三方收到企业号平台发送的消息
|
|
|
String plainMessage = pc.decrypt(cipherText);
|
|
|
String plainMessage = pc.decrypt(cipherText);
|
|
|
|
|
|
|
|
|
System.out.println(plainMessage);
|
|
|
System.out.println(plainMessage);
|
|
|
|
|
|
|
|
|
assertEquals(plainMessage, replyMsg);
|
|
|
assertEquals(plainMessage, replyMsg);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|