The exact diagonalization solver of the surface mode of topological insulators