You can do it with a pretty straightfoward Geometry Nodes modifier :
On a new object, add a Geometry Nodes modifier.
Do the boolean difference of Object A with B, and then B with A.
You'll end up with two meshes separated by one or several edge lines at their intersection.
Then compute the distance between each vertex of one of the meshes and the vertices ...