Finding vector potential from a given magnetic field

I want to find the vector potential from a given magnetic field in three-dimension in cartesian coordinates for two cases. 1) Where the magnetic field is in any analytical form and 2) When the magnetic field is any random number (numerical).