What you need to do is compute de = 1 mod phi (n). This is actually very fast - you just need to use the advanced Euclidean algorithm on e and phi n. This will allow you to calculate de + k \ phi (n) = 1, i.e. you calculated the inverse of e under \ phi (n).
Edit, Rasmus Faber is correct, you need to check that gcd (e, \ phi (n)) = 1. The advanced Euclidean algorithm will still be for you - you calculate both gcd and the multiplicity e, phi (n). This tells you what d is, namely, that d is inverse to e, modulu phi n, which tells you that t ^ ed = t ^ 1 modulo phi n.
Regarding this in practice, I highly recommend using the bignum library ; Promoting your own arbitrary algorithm with an extended Euclidean value is not easy. Here is one such function that will do this effectively for arbitrary precision arithmetic.
user257111
source share