完善RSA大数据数字信封

This commit is contained in:
yihzhou
2022-10-28 11:20:22 +08:00
parent c95130c6ed
commit fd6ef6050f
4 changed files with 501 additions and 193 deletions
+5 -3
View File
@@ -21,7 +21,7 @@ import java.util.List;
import static com.sunyard.sydapi.util.PrintUtil.printRetWrap;
public class Shanghairenhang {
private static final byte[] orgData2k = new byte[ 16 ];
private static final byte[] orgData2k = new byte[ 5*1024 ];
private static final String pcDnEN = "C=CN,O=CFCA OCA1,OU=YCCA,OU=Individual-2,CN=YCCA@黄金交易所@Zhuangj@1";
private static final String RSA = "C=cn,O=CFCA TEST CA,OU=NCS2,OU=Enterprises,CN=041@Z402451000010@ShanDong@00000001";
@@ -41,7 +41,7 @@ public class Shanghairenhang {
* @param pcData: 明文数据。
* @return RetWrap: 数字信封
*/
RetWrap signData = api.generateDEByDn(0,RSA, orgData.getBytes());
RetWrap signData = api.generateDEByDn(4,RSA, orgData2k);
byte[] cpkey2 = (byte[]) signData.get("CipherKey");
System.out.println("加密信封:" + new String(cpkey2));
@@ -51,10 +51,12 @@ public class Shanghairenhang {
* @param cpkey: 数字信封。
* @return preData: 原数据
*/
RetWrap oDataWrap = api.decryptDEByDN(0,RSA, cpkey2);
RetWrap oDataWrap = api.decryptDEByDN(4,RSA, cpkey2);
byte[] preData = (byte[]) oDataWrap.get("oData");
System.out.println("解密信封:" + Util.bytes2HexString(preData));
//
} catch (Exception e) {