check-sign-fbmc-light

check sign use Hmac-MD5

Usage no npm install needed!

<script type="module">
  import checkSignFbmcLight from 'https://cdn.skypack.dev/check-sign-fbmc-light';
</script>

README

check-sign-fbmc-light

使用Hmac-MD5对请求和相应增加签名、验签

客户端使用方法

import { CheckSignFbmcClient } from "check-sign-fbmc-light";

(async function(){
    const secret = `123456`;
    const client = new CheckSignFbmcClient(secret, { debug: true });
    const request = { a: "1" };
    const requestWithSign = client.addSignToRequest(request);
    const responseWithSign = await axios.post("/api", requestWithSign);

    const clientCheckSignResult = client.checkSign(responseWithSign);
})();

服务端使用方法

import { CheckSignFbmcServer } from "check-sign-fbmc-light";

(async function(requestWithSign){
    const secret = `123456`;
    const server = new CheckSignFbmcServer(secret, { debug: true });
    const serverCheckSignResult = server.checkSign(requestWithSign);
    const response = { a: "1" };
    const responseWithSign = server.addSignToResponse(response);
})();