I'll provide the complete solution to the integral. Inside the proof, I've detailed by the side integrals tend towards zero along with how to complete the proof, in case you were having trouble with it.
Denote the function $f(z)$ as$$f(z)=\frac {e^{az}}{\cosh z}$$And take the rectangular contour with vertices of $\pm R$ and $\pm R+\pi i$.

Integrating about each section of the contour $\mathrm C$, the contour integral is equal to$$\begin{multline}\oint\limits_{\mathrm C}\mathrm dz\, f(z)=\int\limits_{-R}^{R}\mathrm dx\, f(x)+i\int\limits_0^{\pi}\mathrm dx\, f(R+\pi i)-\int\limits_{-R}^{R}\mathrm dx\, f(x+\pi i)-i\int\limits_0^{\pi}\mathrm dx\, f(-R+\pi i)\end{multline}$$Now let's observe the second, third, and fourth integral separately. From the function $f(z)$, it should be quite obvious what each of the integrands are$$\begin{align*}f(R+\pi i) & =-\frac {e^{a(R+\pi i)}}{\cosh R}\sim -e^{\pi a i}e^{R(a-1)}\\f(-R+\pi i) & =-\frac {e^{a(-R+\pi i)}}{\cosh R}\sim -e^{\pi a i}e^{-R(a+1)}\\f(x+\pi i) & =-\frac {e^{a(x+\pi i)}}{\cosh x}=-e^{\pi a i}f(x)\end{align*}$$
Note that in the first two equations, I've used the fact that $\operatorname{sech} x$ behaves like $e^{-x}$ for large values of $x$. Now we use the fact that $|a|<1$. This means that $a$ will always be a fraction smaller than one. Hence, for the first equality, $a-1<0$. What this means is that the exponential function is actually decreasing which means as $R\to\infty$, then$$\int\limits_0^{\pi}\mathrm dx\, f(R+\pi i)\xrightarrow{\phantom{hello}}0$$Similarly, the second equality tends towards zero because $a$ will be a positive number if added by one, so the exponential function is once again negative. Therefore$$\int\limits_0^{\pi}\mathrm dx\, f(-R+\pi i)\xrightarrow{\phantom{hello}}0$$
What's left now is$$\oint\limits_{\mathrm C}\mathrm dz\, f(z)=(1+e^{\pi a i})\int\limits_{-\infty}^{\infty}\mathrm dx\, f(x)$$The contour integral is also equal to $2\pi i$ times the sum of its residues. The rectangular contour encloses only one singularity at $z=\tfrac {\pi i}2$ of order one. Therefore, the calculations are as follows$$\begin{align*}\operatorname*{Res}_{z\, =\, \tfrac {\pi i}2}f(z) & =\lim\limits_{z\,\to\,\tfrac {\pi i}2}\frac {\left(z-\tfrac {\pi i}2\right)e^{az}}{\cosh z}\\ & =\frac {e^{\pi a i/2}}i\end{align*}$$Thus$$\begin{align*}\int\limits_{-\infty}^{\infty}\mathrm dx\, f(x) & =\frac {2\pi e^{\pi a i/2}}{1+e^{\pi a i}}\end{align*}$$
Dividing both the numerator and denominator by $e^{\pi a i/2}$ for simplification finally gives the closed form as$$\int\limits_{-\infty}^{\infty}\mathrm dx\,\frac {e^{ax}}{\cosh x}\color{blue}{=\pi\sec\left(\frac {\pi a}2\right)}$$The proof for the second part of the question can be completed by replacing $a$ with $ni$ and taking the real part of both sides.