I need to interface with third-party organizations. They need to add a digital signature to the data and put it in the request header.
I found that jsrsasign.js could be helpful so I am using that to do the digital signature, but always with the wrong result.

my code:
import { RSAKey, KEYUTIL, KJUR, hex2b64 } from 'jsrsasign'
export function signature (url) {
// 创建RSAKey对象
var rsa = new RSAKey()
let k = '-----BEGIN PRIVATE KEY-----x-----END PRIVATE KEY-----'
// 将密钥转码
rsa = KEYUTIL.getKey(k)
// 创建Signature对象,设置签名编码算法
var sig = new KJUR.crypto.Signature({'alg': 'SHA256withRSA'})
// 初始化
sig.init(rsa)
console.log('***url***', url)
// 传入待加密字符串
sig.updateString(url)
// 生成密文
var sign = hex2b64(sig.sign())
console.log('**sign**', sign)
return sign
}