Skip to content

Instantly share code, notes, and snippets.

@akavel
Last active May 13, 2019 23:15
Show Gist options
  • Save akavel/bd84e99e4f887543cea9de22d3f473d9 to your computer and use it in GitHub Desktop.
Save akavel/bd84e99e4f887543cea9de22d3f473d9 to your computer and use it in GitHub Desktop.
Tentative apksigner crypto
-----BEGIN CERTIFICATE-----
MIGgMIGVAgEBMAMGAQEwCTEHMAUGAQETADAaFwsxNzEwMTAyMjUwWhcLMTcxMDEw
MjI1MFowCTEHMAUGAQETADBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABLAoWrpy
dzdU6PN096BcSaDRFuC+/8MjLhgeFUiogqlrZFocHudWRHJALK08ge+x0n3nwCVB
wJ4Ybfhm0sf9nowwAwYBAQMBAA==
-----END CERTIFICATE-----
let
privKey = readFile("key.pk8").parsePKCS8PrivateKey()
cert = readFile("cert.x509.pem").decodePEM().parseX509Cert()
message = "A quick brown fox jumps over the lazy dog"
signature = signPKCS7Detached(message, cert, privKey)
if keyType(privKey) == RSAKey:
writeFile("signature.rsa", signature)
elif keyType(privKey) == ECDSAKey:
writeFile("signature.ec", signature)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment