在Android中运行JavaSE代码
如何在Android中运行SignApk.class? 我需要在Android设备上运行此代码,但它无法访问在Android中运行JavaSE代码,java,android,apk,sign,Java,Android,Apk,Sign,如何在Android中运行SignApk.class? 我需要在Android设备上运行此代码,但它无法访问sun.security 和sun.misc要运行此代码,您需要为此添加库,因此我在这里发布了一个到库的链接,请查看该链接并告知我有关问题 链接:- /** Write a .RSA file with a digital signature. */ private static void writeSignatureBlock( Signature si
sun.security
和
sun.misc
要运行此代码,您需要为此添加库,因此我在这里发布了一个到库的链接,请查看该链接并告知我有关问题
链接:-
/** Write a .RSA file with a digital signature. */
private static void writeSignatureBlock(
Signature signature, X509Certificate publicKey, OutputStream out)
throws IOException, GeneralSecurityException {
SignerInfo signerInfo = new SignerInfo(
new X500Name(publicKey.getIssuerX500Principal().getName()),
publicKey.getSerialNumber(),
AlgorithmId.get("SHA1"),
AlgorithmId.get("RSA"),
signature.sign());
PKCS7 pkcs7 = new PKCS7(
new AlgorithmId[] { AlgorithmId.get("SHA1") },
new ContentInfo(ContentInfo.DATA_OID, null),
new X509Certificate[] { publicKey },
new SignerInfo[] { signerInfo });
pkcs7.encodeSignedData(out);
}