请下载对应语言的工具类:
版本 | 下载附件 |
---|---|
java 版本 (maven项目) | |
Php 版本 | |
Go 版本 |
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)); }
$lySign = new LySign(privateKey, publicKey); $$sign = $$lySign->sign($data);System.out.println("签名数据:" + lySign.sign(data));
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)));
$phone = "18664805491"; $key = "B50BBEF6C4CD4FA8"; $$aes = new LyAes($$key); $$encoded = $$aes->encrypt($phone); echo "手机号加密后:" . $encoded . "\n"; echo "手机号解密:" . $aes->decrypt($encoded) . "\n";