Created
August 6, 2018 02:09
-
-
Save samngms/831675e1e1aa29c8f87c78bfa2082749 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KeyPairGenerator kpGen = KeyPairGenerator.getInstance("RSA"); | |
kpGen.initialize(2048); | |
KeyPair keyPair = kpGen.generateKeyPair(); | |
Random random = new SecureRandom(); | |
byte[] data = new byte[256]; | |
random.nextBytes(data); | |
Cipher cipher = Cipher.getInstance(__RSA_ENCRYPTION__); | |
cipher.init(Cipher.ENCRYPT_MODE, keyPair.getPublic()); | |
byte[] cipherText = cipher.doFinal(data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment