Typicall mistakes: 1. You defined string as "xxxx" but should be only xxxx. 2. For aes-256, key is 32 bytes long but IV is only 16 bytes since block size is still 16 bytes long = as for aes-128. 3. -hmac takes string as the parameter not the file - so -hmac file.txt takes the string as the input so different file name with the same content would result in different HMAC. Solution: 0. Create file seed_file.bin with zero byte (=0x00) and file msg.txt with string "This is my UCO_XXXXXX" as its content. (simple C code, or echo, etc.) 1. rand -out K.bin -rand seed_file.bin 16 (uses seed in binary file seed_file.bin and generates random key to text file K.hex, 32 hex = 16 bytes of random data) 2. rand -out IV.bin -rand K.bin 16 (uses K.bin as the seed and generates random IV to binary file IV.bin) 3. enc -e -aes-128-cbc -in msg.txt -out msg_enc.txt -K "hexdump of K.bin" -iv "hexdump of K.bin" -nosalt -p enc -e -aes-128-cbc -in msg.txt -out msg_enc.txt -K "b3658972762259e645f32406b4619503" -iv "4a8358626db934c453028f12d8784baf" -nosalt -p Output: key=B3658972762259E645F32406B4619503 iv =4A8358626DB934C453028F12D8784BAF (IV and K are accepted only as hex strings, -p to see IV,K) 4. dgst -sha256 -mac HMAC -macopt key:"sharedsecret" msg.txt Output: HMAC-SHA256(msg.txt)= f3d242ecf6add4fc17c61e20dfa4e3cb8110eb54fcb03a367ba629488634e951 (computes HMAC using sha256 with string as secret) 5. enc -d -aes-128-cbc -in msg_enc.txt -out msg_dec.txt -K "b3658972762259e645f32406b4619503" -iv "4a8358626db934c453028f12d8784baf" -nosalt -p (for decryption -d is used instead of -e) Output: key=B3658972762259E645F32406B4619503 iv =4A8358626DB934C453028F12D8784BAF dgst -sha256 -mac HMAC -macopt key:"sharedsecret" msg_dec.txt Output: HMAC-SHA256(msg_dec.txt)= f3d242ecf6add4fc17c61e20dfa4e3cb8110eb54fcb03a367ba629488634e951 6. Files are almost equal i.e. are of the form FILE1 = B | M1 | B2, FILE2 = B | M2 | B2, starting and ending with the same blocks B1,B2. To create the new collsiion you can append,prepend same arbitrary block to both files or to change (same change should be applied to both) block B or/and B2 in both files.