Various code is available online for finding magic hexagons:
some ECLiPSe code
some LPA code
some C code
some other C code due to Phil J. Taylor.
some Koalog code