Java:
Signature sig = Signature.getInstance("SHA1withRSA"); sig.initSign(rsaPrivateKey); sig.update(data); locallySigned = sig.sign();
c#:
/// <summary> /// RSA签名 /// </summary> /// <param name="privateKey">私钥</param> /// <param name="content">待签名内容</param> /// <returns></returns> public static string Signature(string privateKey,string content,Encoding encode) { RSACryptoServiceProvider rsaProvider = new RSACryptoServiceProvider(); rsaProvider.FromXmlString(privateKey); SHA1 sha1 = SHA1.Create(); byte[] signature = rsaProvider.SignData(encode.GetBytes(content), sha1); return Convert.ToBase64String(signature); }