DPI-C in SystemVerilog Testbench (Output of C Model is not matching with SV output)

In reply to yasirdv:

You only allocate 4 characters for your out_cipher, hence only 4 characters being returned. You also have an out of bounds access error when setting out_cipher[4] to ‘\0’, as out_cipher only goes from 0 to 3.