diff --git a/README.md b/README.md index 95117ec..35fb985 100644 --- a/README.md +++ b/README.md @@ -42,11 +42,17 @@ $associatedData = "Some data 😋 文 This data is not contained in the encrypt $encrypted = Ascon::encryptToHex($key, $message, $associatedData); $decrypted = Ascon::decryptFromHex($key, $encrypted, $associatedData); -// raw usage (the original implementation with raw values) +// key must be 16 bytes or 20 bytes, depending on variant $key = [0x90, 0x80, 0x70, 0x60, 0x50, 0x40, 0x30, 0x20, 0x10, 0xAA, 0x90, 0x90, 0x90, 0x90, 0xCC, 0xEF]; +// nonce must be 16 bytes and should always be random bytes, you must use same nonce for encrypt and decrypt the same message $nonce = random_bytes(16); +// this is the text you want to encrypt $plaintext = "Hi, i am a secret message!"; -$associatedData = "Some data the will not be encrypted but verified along the plaintext (Decryption will fail if you not provide the exact same data)"; +// associated data is not being encrypted, but is taken into account in the ciphertext +// this means, you can only decrypt when you pass the exact same associated data to the decrypt function as well +// so you can make sure that associated data and plaintext is not manipulated for given encrypted message +// this is optional and can be an empty string +$associatedData = "Some data to pass to encryption and decryption - This data is not contained in the ciphertext output."; $ciphertextByteArray = Ascon::encrypt($key, $nonce, $associatedData, $plaintext); $plaintextDecrypted = Ascon::decrypt($key, $nonce, $associatedData, $ciphertextByteArray); ```