Instantiate Prefab at random

Hello there,
am working puzzle kind of game(3D Game),in my game i used lot of crates and a key. I need to find the key from the crates, my crates are static (static the sense it place a static position). But my key isn’t like that, so i need to give a random position to key(X- Axis and Z-Axis), main thing the key will instantiate only inside the box. If the player play game first, he collect the key from one crate, next time it must appear different crate. The following image will give u the basic sketch about my game.

[1]

-Prasanna

If you are storing your crates in an array, you can simply pick a random value between 0 and the array length, then you can get the object at the array index of the random value you just generated, set the keys location to that crates position.