1234567891011121314 |
- import SM3 from "sm-crypto";
- import Buffer from "vue-buffer";
-
- export function sm3(message, key) {
- const keyBuffer = Buffer.from(key, "utf-8");
- const messageBuffer = Buffer.from(message, "utf-8");
- const hmac = SM3.sm3(messageBuffer, { key: keyBuffer });
- const mac = SM3.sm3(messageBuffer);
- if (key) {
- return hmac?.toUpperCase();
- } else {
- return mac?.toUpperCase();
- }
- }
|