An apparatus for generating codes includes a quantization unit which
generates quantization coefficients by performing discrete wavelet
transform with respect to each of tiles into which an image is divided, a
block division unit which divides the quantization coefficients into
blocks, a Hash conversion unit which performs Hash conversion based on
the quantization coefficients of each of the blocks so as to produce a
Hash value for each of the blocks, a digital watermark embedding unit
which adjusts a parity of a quantization coefficient of interest equal to
a parity of the Hash value of a block to which the quantization
coefficient of interest belongs, and a coding unit which generates code
sequence data by coding the quantization coefficients including the
quantization coefficient whose parity is adjusted.