Giter VIP home page Giter VIP logo

Comments (6)

lpilp avatar lpilp commented on August 13, 2024 1

应该是没有问题的吧,我试过python, js的,同一个 msg, 同样的key, 算出来的字符串是一样的,可能是你的用法不对,你可以给个例子,我看看,你的加密串,测试用的公私钥等(不太方便的话,你的代码就用我的test中的那个公私钥),还有你的加解密中出现的问题

from phpsm2sm3sm4.

lpilp avatar lpilp commented on August 13, 2024 1

他就是sm2的非对称加密,返回值是base64编码的,你用我给的例子就行,修改下公钥,我这返回的是16进制的,java给的是base64, 你再将转换下就行了,base64_encode(hex2bin($m2EncryptData)) ,例子原码见 test/tsm2_encrypt.php,
`require_once '../vendor/autoload.php';
use Rtgm\sm\RtSm2;
$sm2 = new RtSm2();
$publicKey = '043d9d4cc71a285af936b36880fd4d6155c22957cd2c84ea313469065207fb951b9ef1db79d69af8886e91e833da1ebc6bfdde86e70f52923d6e042eaa147624c7'; // 公钥

$document = '6220123455553';
// sm2的非对称加解密,不建议加密太长的字符串
$m2EncryptData = $sm2 ->doEncrypt($document, $publicKey);
echo ("加密后: ".$m2EncryptData);`

from phpsm2sm3sm4.

lpilp avatar lpilp commented on August 13, 2024 1

觉得好使,给个赞吧 ^_^

from phpsm2sm3sm4.

xiaochao23 avatar xiaochao23 commented on August 13, 2024

我这边是对接接口,对方只给我提供了公钥,还有用java写的加密过程,我是看不明白java,java的加密代码片段如下
270e1139fe64b69fc580500a2c10791

from phpsm2sm3sm4.

xiaochao23 avatar xiaochao23 commented on August 13, 2024

搜得斯奈,我试一下,谢谢啊

from phpsm2sm3sm4.

xiaochao23 avatar xiaochao23 commented on August 13, 2024

我加星了,谢谢大佬

from phpsm2sm3sm4.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.