Make some value on the computer - say "code"
start of level -> set code to random(10000)
Give the boxes another value "digit" which will be the digit they show when opened
set each box's initial value digit value to numbers from 0 to 3, each with a unique value, (The effect of this is that the 0 box will show the 1st digit, the 1 will show the 2nd etc)
add a sub-event to the start of level event:
for each box -> set digit to middle(zeropad(computer.value('code'),4),'digit',1)
EDIT: (actually this for each box might not be necessary, can probably just put the action in the start of level event)
You may have to set the initial values to 1 to 4, I dunno if 0 or 1 in that parameter of the middle expression gives the first digit. Try this if it doesn't work.
This is also assuming you're only having one of these doors, would be more complex with multiple ones, but doable by adding another value to the boxes and setting them to the computers UID (or a corresponding extra value on the computer. EDIT: or indeed with containers but then you'd have to make different objects for each box and use a family for the stuff above, which is a bit messier).
When you need to display the digits, the value you need is 'digit', the value to test if its correct is computer's 'code' value.