We propose a general framework for differential and linear cryptanalysis of block ciphers when the block is not a bitstring. We prove piling-up lemmas for the generalized differential probability and the linear potential, and we study their lower bounds and average value, in particular in the case of permutations of Fp. Using this framework, we describe a toy cipher, that operates on blocks of 32 decimal digits, and study its security against common attacks.