-
-
Save secondsun/c1fb32a4c49f9bb6bed2 to your computer and use it in GitHub Desktop.
Encryption Services usage examples
This file contains 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
PassPhraseKeyServices.PassPhraseCryptoConfig config = new PassPhraseKeyServices.PassPhraseCryptoConfig(); | |
config.setPassphrase("testPhrase"); | |
config.setSalt(SALT); | |
PassPhraseKeyServices service = new PassPhraseKeyServices(getActivity(), config); | |
String message = "This is a test message"; | |
byte[] encrypted = service.encrypt(message.getBytes()); | |
byte[] decrypted = service.decrypt(encrypted); | |
assertTrue(Arrays.equals(decrypted, message.getBytes())); |
This file contains 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
String message = "This is a test message"; | |
PasswordKeyServices.PasswordProtectedKeystoreCryptoConfig config = new PasswordKeyServices.PasswordProtectedKeystoreCryptoConfig(); | |
config.setAlias("TestAlias"); | |
config.setPassword("testPhrase"); | |
PasswordKeyServices service = new PasswordKeyServices(config, getActivity()); | |
byte[] encrypted = service.encrypt(TestVectors.CRYPTOBOX_IV.getBytes(), message.getBytes()); | |
assertFalse(Arrays.equals(encrypted, message.getBytes())); | |
byte[] decrypted = service.decrypt(TestVectors.CRYPTOBOX_IV.getBytes(), encrypted); | |
assertTrue(Arrays.equals(decrypted, message.getBytes())); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment