The paper moves a step towards the full integration of statistical mechanics and information theory. Starting from the assumption that the thermodynamical system is composed by particles whose quantized energies can be modelled as independent and identically distributed random variables, the paper proposes an approach whose cornerstones are the informationtheoretic typical set and the conditional equiprobability of microstates given certain macrostates of the system. When taken together, these two concepts explain why the standard assumption of equally probable microstates is non-necessary (if not misleading) and show that the celebrated Boltzmann-Planck entropy is indeed a conditional entropy with deterministic condition. Several new specific results of physical relevance are derived from this approach, among which are the probability distribution of the occupancy numbers of the energy levels, the probability distribution of the total quantum number in a system of monochromatic quantum harmonic oscillators at the thermal equilibrium, an exact formula for the ideal gas in a container that gives the entropy of the gas also at low temperature. These specific results are pieces of a self-consistent and unified framework that encompasses the cases of low and high temperature, of indexed and non-indexed particles, of small and large number of particles, of microcanonical, canonical and grand canonical ensembles.