-
-
Save MichalGniadek/f48a05ae2008203ce3ef92235cb7bc49 to your computer and use it in GitHub Desktop.
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
@Override | |
public void onMessageReceived(RemoteMessage message) { | |
try { | |
AESCryptoModuleCompat obj = new AESCryptoModuleCompat(); | |
byte[] key = obj.generateKey(); | |
String plaintext = "test_data!"; | |
byte[] sealedData = | |
obj.encrypt(key, plaintext.getBytes(StandardCharsets.UTF_8)); | |
String decrypted = | |
new String(obj.decrypt(key, sealedData), StandardCharsets.UTF_8); | |
Log.w("COMM", "Decrypted text: " + decrypted); | |
} catch (Exception e) { | |
Log.w( | |
"COMM", | |
"Failed to run generate key -> encrypt -> decrypt sequence.", | |
e); | |
} | |
// ...omitted in gist... | |
} |
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
import * as AES from '../utils/aes-crypto-module.js'; | |
const key = AES.generateKey(); | |
const plaintext = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); | |
const sealedData = AES.encrypt(key, plaintext); | |
const plaintext2 = AES.decrypt(key, sealedData); | |
console.log(` | |
key: ${key.toString()} | |
plaintext: ${plaintext.toString()} | |
sealedData: ${sealedData.toString()} | |
plaintext2: ${plaintext2.toString()} | |
`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment