We describe a novel multimedia security framework based on a modification of the arithmetic coder, which is used by most international image and video coding standards as entropy coding stage. In particular, we propose a randomized arithmetic coding paradigm, which achieves encryption by randomly swapping the intervals of the least and most probable symbols in arithmetic coding; moreover, we describe an implementation tailored to the JPEG 2000 standard. The proposed approach turns out to be robust towards attempts to discover the key, and allows very flexible procedures for insertion of redundancy at the codeblock level, allowing to perform total and selective encryption, conditional access, and encryption of regions of interest.