在APP里找到如下:
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.spec.PKCS8EncodedKeySpec;
public class SignUtils
{
private static final String ALGORITHM = "RSA";
private static final String DEFAULT_CHARSET = "UTF-8";
private static final String SIGN_ALGORITHMS = "SHA1WithRSA";
public static String sign(String paramString1, String paramString2)
{
try
{
PKCS8EncodedKeySpec localPKCS8EncodedKeySpec = new PKCS8EncodedKeySpec(Base64.decode(paramString2));
PrivateKey localPrivateKey = KeyFactory.getInstance("RSA").generatePrivate(localPKCS8EncodedKeySpec);
Signature localSignature = Signature.getInstance("SHA1WithRSA");
localSignature.initSign(localPrivateKey);
localSignature.update(paramString1.getBytes("UTF-8"));
String str2 = Base64.encode(localSignature.sign());
str1 = str2;
return str1;
}
catch (Exception localException)
{
while (true)
{
localException.printStackTrace();
String str1 = null;
}
}
}
}