String keystr="private key";
Byte [] keybyte=HexBin. Decode (keystr);
PKCS8EncodedKeySpec PKCS8EncodedKeySpec=new PKCS8EncodedKeySpec (keybyte);
KeyFactory KeyFactory=KeyFactory. GetInstance (" EC ");
PrivateKey PrivateKey=keyFactory. GeneratePrivate (pkcs8EncodedKeySpec);
Signature Signature=Signature. GetInstance (" SHA1withECDSA ");
Signature. InitSign (privateKey);
Signature. The update (SRC) getBytes (" utf-8 "));
Byte [] arr=signature. Sign ();
Sign=HexBin. Encode (arr);
The above Java code needs to be converted into c # code, test for a long time didn't succeed,
Please help, thank you.
CodePudding user response:
The wrong information "SHA1withECDSA" is the signature algorithmKey generation PKCS8EncodedKeySpec
So you into two-step, regardless of the algorithm first part, Mr Into key, and then to find the algorithm
PKCS8EncodedKeySpec look from the name is a PKCS # 8 format for RSA keys
So Google first "c # RSA PKCS # 8" (this with Google, baidu is difficult)
Below are the results
https://www.google.com/search? Ei=AzJvXfnnOsni - Ab5paP4Dw & amp; Q=C % 23 + RSA + PKCS % 238 & amp; Oq=C % 23 + RSA + PKCS % 238 & amp; Gs_l=psy - ab. 3... 478158.478158.. 479125... 0.0.. 0.0.0... 0... 2 j1.. GWS - wiz. 4 qhof1miymg & amp; Ved=0 ahukewi59bonn7bkahvjmd4khfnscp8q4dudcas & amp; Uact=5
Then find "SHA1withECDSA" algorithm, this is part of a RSA algorithm is a kind of
So, find the following things
https://blog.csdn.net/kevin860/article/details/82323116
Ps: don't want to keep looking, do you know the key information, I think you can find all your information
CodePudding user response:
Ecdsa can refer to, looked like is there a difference in this articleCodePudding user response:
Incidentally, basically has a received data in the same placeBouncyCastle
So he went to a check on the nuget
https://www.nuget.org/packages/BouncyCastle/
Find the official instructions look a the
Reference