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