Use Notifications Master app ID

This commit is contained in:
ajp_anton
2026-08-16 01:57:44 +00:00
parent 572660a967
commit af3673c2e8
51 changed files with 142 additions and 142 deletions
@@ -0,0 +1,28 @@
package se.ajpanton.notificationsmaster.data
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
import javax.crypto.KeyGenerator
class AesGcmCipherTest {
@Test
fun roundTripsDataWithoutLeavingItInCipherText() {
val key = KeyGenerator.getInstance("AES").apply { init(256) }.generateKey()
val plainText = "private notification content".encodeToByteArray()
val encrypted = AesGcmCipher(key).encrypt(plainText)
assertFalse(encrypted.cipherText.decodeToString().contains("private notification content"))
assertTrue(AesGcmCipher(key).decrypt(encrypted).contentEquals(plainText))
}
@Test(expected = javax.crypto.AEADBadTagException::class)
fun rejectsTamperedCipherText() {
val key = KeyGenerator.getInstance("AES").apply { init(256) }.generateKey()
val encrypted = AesGcmCipher(key).encrypt("message".encodeToByteArray())
encrypted.cipherText[0] = (encrypted.cipherText[0].toInt() xor 1).toByte()
AesGcmCipher(key).decrypt(encrypted)
}
}