You need to enable JavaScript to run this app.
导航
API 接入步骤
最近更新时间:2024.12.20 16:16:51首次发布时间:2024.12.20 16:16:51

步骤一:生成接口签名

请下载对应语言的工具类:

版本

下载附件

java 版本 (maven项目)

H5一键登录java版工具类.zip
未知大小

Php 版本

H5一键登录php版工具类.zip
未知大小

Go 版本

H5一键登录Go版工具类.zip
未知大小

Java 版本

public static void testGenSign() throws NoSuchAlgorithmException {
        System.out.println("生成签名demo:=================");
        System.out.println("当前公钥:" + publicKey);
        System.out.println("当前私钥:" + privateKey);
        System.out.println();
        String appId = "300012034469";
        String traceId = "78be31760e824862816b2ae9a3a220e2";
        String timestamp = "20210426094753203";
        String token = "H5HTTPS855239703d5157accf98686a8595d360d70869a6e29b4b13af986a90d6dbe078";
        String version = "1.0";
        String data = appId + traceId + timestamp + token + version;

        System.out.println("待签名数据:" + data);
        // 注意:如果公私钥是base64格式的,则最后一个参数是false,否则为true
        LySign lySign = LySign.of(SignAlgorithm.SHA256withRSA, privateKey, publicKey, hexStr);
        String sign = lySign.sign(data);
        System.out.println("签名数据:" + sign);
        System.out.println("验证结果:" + lySign.verify(data, sign));
}

PHP 版本

$lySign = new  LySign(privateKey, publicKey);
$$sign = $$lySign->sign($data);System.out.println("签名数据:" + lySign.sign(data));

步骤二:通过 AES 解密手机号

Java版本

String phone = "18664805491";
String key = "B50BBEF6C4CD4FA8" //截取appkey前16位进行手机号解密
AES aes = new AES(getAesKey(key));
String encoded = aes.encryptBase64(phone.getBytes(StandardCharsets.UTF_8));
System.out.println("手机号加密后:" + encoded);
System.out.println("手机号解密:" + new String(aes.decryptBase64(encoded)));

PHP 版本

$phone = "18664805491";
$key = "B50BBEF6C4CD4FA8";
$$aes = new LyAes($$key);
$$encoded = $$aes->encrypt($phone);
echo "手机号加密后:" . $encoded . "\n";
echo "手机号解密:" . $aes->decrypt($encoded) . "\n";