Why is Python encryption failing