Java代码如下
//密钥
String key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
byte[] keyByte = Base64.decodeBase64(key);
PKCS8EncodedKeySpec pkcs8EncodedKeySpec = new PKCS8EncodedKeySpec(keyByte);
KeyFactory keyFactory = KeyFactory.getInstance("EC");
PrivateKey privateKey = keyFactory.generatePrivate(pkcs8EncodedKeySpec);
Signature signature = Signature.getInstance("SHA1withECDSA");
signature.initSign(privateKey);
signature.update("1122334455667788".getBytes());
byte[] res = signature.sign();
System.out.println("签名:" + Base64.encodeBase64String(res));
看网上的解决方案, GetPrivateKeyParameter(key);改怎么实现
AsymmetricKeyParameter priKey = GetPrivateKeyParameter(key);
byte[] byteData = System.Text.Encoding.UTF8.GetBytes(data);
ISigner normalSig = SignerUtilities.GetSigner("SHA1withECDSA");
normalSig.Init(true, priKey);
normalSig.BlockUpdate(byteData, 0, byteData.Length);
byte[] normalResult = normalSig.GenerateSignature(); //签名结果
return Convert.ToBase64String(normalResult);