运行 Java Android 中的 SE 代码
Run Java SE code in Android
如何在Android中运行SignApk.class
运行?
https://www.dropbox.com/s/bi1ckssvrq20b58/SignApk.java
/** 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);
}
我需要在 Android 台设备中 运行 此代码,但它无法访问 sun.security
和 sun.misc
.
到 运行 这段代码你需要为此添加库,所以在这里我将 link 发布到库中,请仔细阅读并让我知道问题
Link:- http://www.java2s.com/Code/Jar/a/Downloadandroidsunjarsignsupport11jar.htm
如何在Android中运行SignApk.class
运行?
https://www.dropbox.com/s/bi1ckssvrq20b58/SignApk.java
/** 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);
}
我需要在 Android 台设备中 运行 此代码,但它无法访问 sun.security
和 sun.misc
.
到 运行 这段代码你需要为此添加库,所以在这里我将 link 发布到库中,请仔细阅读并让我知道问题
Link:- http://www.java2s.com/Code/Jar/a/Downloadandroidsunjarsignsupport11jar.htm