Uses 15838K of libraries. Click here for Pure Java version (2215L/12K).
!7 !include once #1030462 // BouncyCastle cprint { KeyPair generateKeyPair() ctex { ECNamedCurveParameterSpec parameterSpec = ECNamedCurveTable.getParameterSpec(nl.martijndwars.webpush.Utils.CURVE); KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(nl.martijndwars.webpush.Utils.ALGORITHM, org.bouncycastle.jce.provider.BouncyCastleProvider.PROVIDER_NAME); keyPairGenerator.initialize(parameterSpec); ret keyPairGenerator.generateKeyPair(); } start-thread { Provider provider = Security.getProvider(org.bouncycastle.jce.provider.BouncyCastleProvider.PROVIDER_NAME); print("Provider:" + provider); if (provider == null) { Security.addProvider(new BouncyCastleProvider); provider = Security.getProvider(org.bouncycastle.jce.provider.BouncyCastleProvider.PROVIDER_NAME); print("Provider:" + provider); } KeyPair keyPair = generateKeyPair(); ECPublicKey publicKey = cast keyPair.getPublic(); ECPrivateKey privateKey = cast keyPair.getPrivate(); byte[] encodedPublicKey = nl.martijndwars.webpush.Utils.encode(publicKey); byte[] encodedPrivateKey = nl.martijndwars.webpush.Utils.encode(privateKey); print("Public key: " + base64encode(encodedPublicKey)); print("Private key: " + shorten(16, base64encode(encodedPrivateKey))); } }
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030460 |
Snippet name: | Test web-push-libs [generate key] |
Eternal ID of this version: | #1030460/11 |
Text MD5: | e537fcf106405002ab0ea6a5cf8f1c8a |
Transpilation MD5: | 64c7eb6c8308eda7e6a2a4dc44accfdf |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-12-21 17:16:17 |
Source code size: | 1382 bytes / 35 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 183 / 327 |
Version history: | 10 change(s) |
Referenced in: | [show references] |