Generalized encryption of plain text