Given an n × n matrix A over a field F and a scalar a ∈ F , we consider the linear codes C(A, a) := {B ∈ F n×n | AB = aBA} of length n 2 . We call C(A, a) a twisted centralizer code. We investigate properties of these codes including their dimensions, minimum distances, parity-check matrices, syndromes, and automorphism groups. The minimal distance of a centralizer code (when a = 1) is at most n, however for a = 0, 1 the minimal distance can be much larger, as large as n 2 .