通用接口参数加密示例

简要描述
  • 接口参数生成、加密、解密示例
通用请求参数
参数名 是否必选 类型 说明
organizationCode 必选 String 企业编号
data 必选 String 已加密数据;
备注:
请将原始数据进行RSA加密,,再URLEncoder.encode两次
rand 必选 String 6位随机数
requestTime 必选 String 请求时间
格式: yyyyMMddHHmmss
例子: 20210726120000
sign 必选 String 签名值(64位字母大写)示例:SHA256(data+organizationCode+requestTime+rand+MD5Key)
备注:
data请使用已RSA加密的原始数据(未URLEncoder.encode两次)
MD5Key(MD5秘钥) 在登入后首页的企业信息
请求加密流程
第一、生成data 参数。请参考 '请求 Data 示例' 。
第二、以公钥加密data 参数。请参考 '请求 Data RSA加密示例' 。
第三、生成sign 参数。请参考 '请求 Sign 生成示例' 。
第四、URL encode 加密数据(data 参数) 两次 。请参考 '请求报文示例'
请求 Data 示例
充值金額: "0.1"
充值类型: "AliPayHK"
支付设备类型: "Web"
通知地址: "http://127.0.0.1:8205/api/testNotifyUrl"

Data 示例:
{"deviceType":"Web","rechargeAmount":"0.1","netwayCode":"AliPayHK","notifyUrl":"http://127.0.0.1:8205/api/testNotifyUrl"}
请求 Data RSA加密示例
原始数据:
{"deviceType":"Web","rechargeAmount":"0.1","netwayCode":"AliPayHK","notifyUrl":"http://127.0.0.1:8205/api/testNotifyUrl"}
加密数据 (RSA公钥加密后,进行URLEncoder.encode两次前):
hUeXTPvZtCbkn6SgHkX7m/HbN+KCD+0eAQVBrnaoQI2jaAelzJv5TUKsEaCNwnUO0k/RabwdYkRfeedWTM60DErWC+SAy/oVT3e8FhCMMkR3L0VAbw1VPOMnH1GQ424zZ19jb4q3Kt1ScoU4g/ZW/4Kg0B2dIVfDuJDR3AFuNcZdulkkMA8NNUPM8JQbOt9w+lzDLdWb5GEXSFrToboNsHPENW2EHXJKOv6Nd5+PiwWsPtJftaVK+kXzgqMt3+S3/56CXucLn9kh5A652xCD204YhuqwCZtgcq63ROIj1YHaCeP4aOn4m8mRs3TwgSaqf9b2UAeRomVQ6yQjWAPQLA==
加密数据 (RSA公钥加密后,进行URLEncoder.encode两次後):
hUeXTPvZtCbkn6SgHkX7m%252FHbN%252BKCD%252B0eAQVBrnaoQI2jaAelzJv5TUKsEaCNwnUO0k%252FRabwdYkRfeedWTM60DErWC%252BSAy%252FoVT3e8FhCMMkR3L0VAbw1VPOMnH1GQ424zZ19jb4q3Kt1ScoU4g%252FZW%252F4Kg0B2dIVfDuJDR3AFuNcZdulkkMA8NNUPM8JQbOt9w%252BlzDLdWb5GEXSFrToboNsHPENW2EHXJKOv6Nd5%252BPiwWsPtJftaVK%252BkXzgqMt3%252BS3%252F56CXucLn9kh5A652xCD204YhuqwCZtgcq63ROIj1YHaCeP4aOn4m8mRs3TwgSaqf9b2UAeRomVQ6yQjWAPQLA%253D%253D

publicKey(公钥): MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVTxgtusLZpxShBjA0SkBfRMuodyEo/UNrRoyMWBMJajACN0UIQE94mU765EKLMckWjH5f0R8V3QRpmVhxXGoV/INOQEmFR133Oc29LilYUov1CFhnf0F79OE7aJcbPko3gk/7aeqGHvEXABkwmXM51tMwZgepBU8cIlyXPJqHSQIDAQAB
privateKey(私钥): MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJVPGC26wtmnFKEGMDRKQF9Ey6h3ISj9Q2tGjIxYEwlqMAI3RQhAT3iZTvrkQosxyRaMfl/RHxXdBGmZWHFcahX8g05ASYVHXfc5zb0uKVhSi/UIWGd/QXv04Ttolxs+SjeCT/tp6oYe8RcAGTCZcznW0zBmB6kFTxwiXJc8modJAgMBAAECgYBDiv9GGJlyupmjalg+H2TVdBqpQBL5JvDrw4NrLaCW/rlvFy+cVvNcfAX1i3Lq4v+zuqSklcZ5Ln2Dg8I1rfey/U5JoEEEWQIRSKPRuAt+XHCuyvk8WS0iaRUysoEGLDW7sjTdmW6G2fU8F+jpLkK03BVKECUvmuAIJB4aa55ZMQJBAOXX+8JOsKxMmS7tzLrAp9C4DqXXbXt+F5hhOKRwpE5ZgxZSRDxY9SpUb62znLz2QoZ5/vHGQXoxnwfK6hGUf9UCQQCmTOZX7cCDE47gJfCJ0JTgO65mGH/uLizc2mc6R1LFqhbM2ltt4Wtw7+BunaBNgNDzXbmqoKZlh8sTc6XqyBelAkAimAeEj2N4C29i6NfPo/+eIpXR0ELiO3BBtyBXX7zbLg3U5jzu+FSuMlc8xbPpnQcWRnZg3X4tbhqJibkBPGChAkEAm1nfHGjnnAsbP11x1OxbBxX5lzpv1+qe0jnckN6r/ickYX3iR0V7fuc3O15Yr84UZCQ8G58zkklGdgdlCWyeWQJAEN8omzmhC2qcdY1VDES69qtH+Vh2IrXyQoHxXGEKHv4Q90ZzV+7wPMwy/HXUK3YqlLfnHW++5CJ887L05FZ1rg==
请求 Sign 生成示例
data: hUeXTPvZtCbkn6SgHkX7m/HbN+KCD+0eAQVBrnaoQI2jaAelzJv5TUKsEaCNwnUO0k/RabwdYkRfeedWTM60DErWC+SAy/oVT3e8FhCMMkR3L0VAbw1VPOMnH1GQ424zZ19jb4q3Kt1ScoU4g/ZW/4Kg0B2dIVfDuJDR3AFuNcZdulkkMA8NNUPM8JQbOt9w+lzDLdWb5GEXSFrToboNsHPENW2EHXJKOv6Nd5+PiwWsPtJftaVK+kXzgqMt3+S3/56CXucLn9kh5A652xCD204YhuqwCZtgcq63ROIj1YHaCeP4aOn4m8mRs3TwgSaqf9b2UAeRomVQ6yQjWAPQLA==
organizationCode: 20210106184413AGVA
requestTime: 20210726150605
rand: vnlzXW
MD5Key: EXCLRCGUPOAHHYJGUXKMNUAMYMQFASFG

Sign 生成公式
= SHA256(data+organizationCode+requestTime+rand+MD5Key)
= SHA256(hUeXTPvZtCbkn6SgHkX7m/HbN+KCD+0eAQVBrnaoQI2jaAelzJv5TUKsEaCNwnUO0k/RabwdYkRfeedWTM60DErWC+SAy/oVT3e8FhCMMkR3L0VAbw1VPOMnH1GQ424zZ19jb4q3Kt1ScoU4g/ZW/4Kg0B2dIVfDuJDR3AFuNcZdulkkMA8NNUPM8JQbOt9w+lzDLdWb5GEXSFrToboNsHPENW2EHXJKOv6Nd5+PiwWsPtJftaVK+kXzgqMt3+S3/56CXucLn9kh5A652xCD204YhuqwCZtgcq63ROIj1YHaCeP4aOn4m8mRs3TwgSaqf9b2UAeRomVQ6yQjWAPQLA==20210106184413AGVA20210726150605vnlzXWEXCLRCGUPOAHHYJGUXKMNUAMYMQFASFG)
= C850DBD998C4664FAC3A0DC3C97FE5FDE90B002DE23D1EB99E95E6A6D002D088
请求报文示例
organizationCode: 20210106184413AGVA
data:hUeXTPvZtCbkn6SgHkX7m%252FHbN%252BKCD%252B0eAQVBrnaoQI2jaAelzJv5TUKsEaCNwnUO0k%252FRabwdYkRfeedWTM60DErWC%252BSAy%252FoVT3e8FhCMMkR3L0VAbw1VPOMnH1GQ424zZ19jb4q3Kt1ScoU4g%252FZW%252F4Kg0B2dIVfDuJDR3AFuNcZdulkkMA8NNUPM8JQbOt9w%252BlzDLdWb5GEXSFrToboNsHPENW2EHXJKOv6Nd5%252BPiwWsPtJftaVK%252BkXzgqMt3%252BS3%252F56CXucLn9kh5A652xCD204YhuqwCZtgcq63ROIj1YHaCeP4aOn4m8mRs3TwgSaqf9b2UAeRomVQ6yQjWAPQLA%253D%253D
rand: vnlzXW
requestTime: 20210726150605
sign: C850DBD998C4664FAC3A0DC3C97FE5FDE90B002DE23D1EB99E95E6A6D002D088

JSON格式
{"organizationCode":"20210106184413AGVA","data":"hUeXTPvZtCbkn6SgHkX7m%252FHbN%252BKCD%252B0eAQVBrnaoQI2jaAelzJv5TUKsEaCNwnUO0k%252FRabwdYkRfeedWTM60DErWC%252BSAy%252FoVT3e8FhCMMkR3L0VAbw1VPOMnH1GQ424zZ19jb4q3Kt1ScoU4g%252FZW%252F4Kg0B2dIVfDuJDR3AFuNcZdulkkMA8NNUPM8JQbOt9w%252BlzDLdWb5GEXSFrToboNsHPENW2EHXJKOv6Nd5%252BPiwWsPtJftaVK%252BkXzgqMt3%252BS3%252F56CXucLn9kh5A652xCD204YhuqwCZtgcq63ROIj1YHaCeP4aOn4m8mRs3TwgSaqf9b2UAeRomVQ6yQjWAPQLA%253D%253D","rand":"vnlzXW","requestTime":"20210726150605","sign":"C850DBD998C4664FAC3A0DC3C97FE5FDE90B002DE23D1EB99E95E6A6D002D088"}
通用响应参数
参数名 类型 说明
code Integer 状态值;200代表成功;其他值都为不成功
code返回为200
data JSON 已加密返回数据;
code返回不为200
message String 请求失敗详情
通用 Data 响应参数
参数名 类型 说明
organizationCode String 企业编号
data String 已加密数据;
备注:
请进行URLDecoder.decode两次,再进行RSA解密
rand String 6位随机数
requestTime String 响应时间
格式: yyyyMMddHHmmss
例子: 20210726120000
sign String 签名值(64位字母大写)示例:SHA256(data+organizationCode+requestTime+rand+MD5Key)
备注:
data请使用已RSA加密的数据(已进行URLDecoder.decode两次)
MD5Key(MD5秘钥) 在登入后首页的企业信息
响应解密流程
第一、URL decode 解密数据(data 参数) 两次 。请参考 '响应 Data RSA 解密示例' 。
第二、生成sign 参数。请参考 '响应 Sign 生成示例' 。
第三、以私钥解密data 参数。请参考 '响应 Data RSA解密示例'
响应示例
{
    "code": 200, 
    "data":        
        {
            "rand":"kPu5Gb",
            "data":"BZuJoSXWmW%252Bqcc%252FVpb02GnRCvtdhuDr29UcLh9JMx1GVVDqHyy5mwxpbozMf7Sy8nCKW3oHj0ZTD7xed5GPLd7kbXkdHp9eTL1bp4WKoIiG2pp9RyRIaRmTXXb13VI%252FS5yx7PT9huzLzujpIY8twC9EJyMhrKipGlZuJ%252FaKrO%252FNr%252B85L5vIYB1iLWs7UC1UtyggC5LpSdZphqqNYpLuSdARHeixBtWCenxodr5I9pyInAYegU32g8nQal0GS4%252FtPRzPmrYq9A12goepL4x98wqLxseBmRxRnNXJHNKy4PtBeahG9%252BA5%252FBxsUrQNwvvnf4zMSVsgrZsIL0efcE0Vu4EzxyGMqYwc69IHA23Y9V65xe7z0vVrsZLcNJX9PTxxIYbRlkw%252BcQi%252BylULM%252BYjFI014bd6SB1cjEjhFqsQ%252FoQGofbptozkA8OfzR9JId9ejaFZUafFSr7J1HxyIkus4bDQdvDOSgTpOR3xvb9KUGZVApvTWgx5jCwVecQa7Q7oW",
            "organizationCode":"20210106184413AGVA",
            "responseTime":"20210726150606",
            "sign":"5338DB63BBAD422206635C7F1F44ADC57A8A1313FD2EBB536E250A567E6D67BF"
        }
}
响应 Sign 生成示例
(注意:请将参数Data进行URLDecoder.decode两次)
data: BZuJoSXWmW+qcc/Vpb02GnRCvtdhuDr29UcLh9JMx1GVVDqHyy5mwxpbozMf7Sy8nCKW3oHj0ZTD7xed5GPLd7kbXkdHp9eTL1bp4WKoIiG2pp9RyRIaRmTXXb13VI/S5yx7PT9huzLzujpIY8twC9EJyMhrKipGlZuJ/aKrO/Nr+85L5vIYB1iLWs7UC1UtyggC5LpSdZphqqNYpLuSdARHeixBtWCenxodr5I9pyInAYegU32g8nQal0GS4/tPRzPmrYq9A12goepL4x98wqLxseBmRxRnNXJHNKy4PtBeahG9+A5/BxsUrQNwvvnf4zMSVsgrZsIL0efcE0Vu4EzxyGMqYwc69IHA23Y9V65xe7z0vVrsZLcNJX9PTxxIYbRlkw+cQi+ylULM+YjFI014bd6SB1cjEjhFqsQ/oQGofbptozkA8OfzR9JId9ejaFZUafFSr7J1HxyIkus4bDQdvDOSgTpOR3xvb9KUGZVApvTWgx5jCwVecQa7Q7oW
organizationCode: 20210106184413AGVA
responseTime: 20210726150606
rand: kPu5Gb
MD5Key: EXCLRCGUPOAHHYJGUXKMNUAMYMQFASFG

Sign 生成公式
= SHA256(data+organizationCode+responseTime+rand+MD5Key)
= SHA256(BZuJoSXWmW+qcc/Vpb02GnRCvtdhuDr29UcLh9JMx1GVVDqHyy5mwxpbozMf7Sy8nCKW3oHj0ZTD7xed5GPLd7kbXkdHp9eTL1bp4WKoIiG2pp9RyRIaRmTXXb13VI/S5yx7PT9huzLzujpIY8twC9EJyMhrKipGlZuJ/aKrO/Nr+85L5vIYB1iLWs7UC1UtyggC5LpSdZphqqNYpLuSdARHeixBtWCenxodr5I9pyInAYegU32g8nQal0GS4/tPRzPmrYq9A12goepL4x98wqLxseBmRxRnNXJHNKy4PtBeahG9+A5/BxsUrQNwvvnf4zMSVsgrZsIL0efcE0Vu4EzxyGMqYwc69IHA23Y9V65xe7z0vVrsZLcNJX9PTxxIYbRlkw+cQi+ylULM+YjFI014bd6SB1cjEjhFqsQ/oQGofbptozkA8OfzR9JId9ejaFZUafFSr7J1HxyIkus4bDQdvDOSgTpOR3xvb9KUGZVApvTWgx5jCwVecQa7Q7oW20210106184413AGVA20210726150606kPu5GbEXCLRCGUPOAHHYJGUXKMNUAMYMQFASFG)
= 5338DB63BBAD422206635C7F1F44ADC57A8A1313FD2EBB536E250A567E6D67BF
响应 Data RSA 解密示例
加密数据 (RSA公钥加密后,进行URLDecoder.decode两次前):
BZuJoSXWmW%252Bqcc%252FVpb02GnRCvtdhuDr29UcLh9JMx1GVVDqHyy5mwxpbozMf7Sy8nCKW3oHj0ZTD7xed5GPLd7kbXkdHp9eTL1bp4WKoIiG2pp9RyRIaRmTXXb13VI%252FS5yx7PT9huzLzujpIY8twC9EJyMhrKipGlZuJ%252FaKrO%252FNr%252B85L5vIYB1iLWs7UC1UtyggC5LpSdZphqqNYpLuSdARHeixBtWCenxodr5I9pyInAYegU32g8nQal0GS4%252FtPRzPmrYq9A12goepL4x98wqLxseBmRxRnNXJHNKy4PtBeahG9%252BA5%252FBxsUrQNwvvnf4zMSVsgrZsIL0efcE0Vu4EzxyGMqYwc69IHA23Y9V65xe7z0vVrsZLcNJX9PTxxIYbRlkw%252BcQi%252BylULM%252BYjFI014bd6SB1cjEjhFqsQ%252FoQGofbptozkA8OfzR9JId9ejaFZUafFSr7J1HxyIkus4bDQdvDOSgTpOR3xvb9KUGZVApvTWgx5jCwVecQa7Q7oW
加密数据 (RSA公钥加密后,进行URLDecoder.decode两次後):
BZuJoSXWmW+qcc/Vpb02GnRCvtdhuDr29UcLh9JMx1GVVDqHyy5mwxpbozMf7Sy8nCKW3oHj0ZTD7xed5GPLd7kbXkdHp9eTL1bp4WKoIiG2pp9RyRIaRmTXXb13VI/S5yx7PT9huzLzujpIY8twC9EJyMhrKipGlZuJ/aKrO/Nr+85L5vIYB1iLWs7UC1UtyggC5LpSdZphqqNYpLuSdARHeixBtWCenxodr5I9pyInAYegU32g8nQal0GS4/tPRzPmrYq9A12goepL4x98wqLxseBmRxRnNXJHNKy4PtBeahG9+A5/BxsUrQNwvvnf4zMSVsgrZsIL0efcE0Vu4EzxyGMqYwc69IHA23Y9V65xe7z0vVrsZLcNJX9PTxxIYbRlkw+cQi+ylULM+YjFI014bd6SB1cjEjhFqsQ/oQGofbptozkA8OfzR9JId9ejaFZUafFSr7J1HxyIkus4bDQdvDOSgTpOR3xvb9KUGZVApvTWgx5jCwVecQa7Q7oW
数据 (RSA私钥解密后):
{
  "payUrlType": "Alipay",
  "code": 200,
  "orderNo": "20210726150605AYXaDF",
  "organizationCode": "20210106184413AGVA",
  "payUrl": "https://vmp.o2pcn.com/VMP/web/payPage?userkey=S0000860&outTradeNo=20210726150605AYXaDF&sign=0b24d5f19ef708614a6fbe03191eac642b7599baf5a8ab201877a42139e557a9"
}

publicKey(公钥): MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVTxgtusLZpxShBjA0SkBfRMuodyEo/UNrRoyMWBMJajACN0UIQE94mU765EKLMckWjH5f0R8V3QRpmVhxXGoV/INOQEmFR133Oc29LilYUov1CFhnf0F79OE7aJcbPko3gk/7aeqGHvEXABkwmXM51tMwZgepBU8cIlyXPJqHSQIDAQAB
privateKey(私钥): MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJVPGC26wtmnFKEGMDRKQF9Ey6h3ISj9Q2tGjIxYEwlqMAI3RQhAT3iZTvrkQosxyRaMfl/RHxXdBGmZWHFcahX8g05ASYVHXfc5zb0uKVhSi/UIWGd/QXv04Ttolxs+SjeCT/tp6oYe8RcAGTCZcznW0zBmB6kFTxwiXJc8modJAgMBAAECgYBDiv9GGJlyupmjalg+H2TVdBqpQBL5JvDrw4NrLaCW/rlvFy+cVvNcfAX1i3Lq4v+zuqSklcZ5Ln2Dg8I1rfey/U5JoEEEWQIRSKPRuAt+XHCuyvk8WS0iaRUysoEGLDW7sjTdmW6G2fU8F+jpLkK03BVKECUvmuAIJB4aa55ZMQJBAOXX+8JOsKxMmS7tzLrAp9C4DqXXbXt+F5hhOKRwpE5ZgxZSRDxY9SpUb62znLz2QoZ5/vHGQXoxnwfK6hGUf9UCQQCmTOZX7cCDE47gJfCJ0JTgO65mGH/uLizc2mc6R1LFqhbM2ltt4Wtw7+BunaBNgNDzXbmqoKZlh8sTc6XqyBelAkAimAeEj2N4C29i6NfPo/+eIpXR0ELiO3BBtyBXX7zbLg3U5jzu+FSuMlc8xbPpnQcWRnZg3X4tbhqJibkBPGChAkEAm1nfHGjnnAsbP11x1OxbBxX5lzpv1+qe0jnckN6r/ickYX3iR0V7fuc3O15Yr84UZCQ8G58zkklGdgdlCWyeWQJAEN8omzmhC2qcdY1VDES69qtH+Vh2IrXyQoHxXGEKHv4Q90ZzV+7wPMwy/HXUK3YqlLfnHW++5CJ887L05FZ1rg==
备注