ruby sm2 加密

openssl
``
key = OpenSSL::PKey::EC.new(“SM2”)
key.generate_key
public_key = key.public_key

public_key_hex = public_key.to_bn.to_s(16).downcase

// 加密
data = “123”
signature = key.dsa_sign_asn1(data)
signature_base64 = Base64.encode64(signature).gsub(“\n”, “”)
``

你可能感兴趣的:(ruby,ruby,开发语言,后端)