That depends on the relative sizes of the hub flanges. If the new hub and the old hub have the same dimensions, then the spokes should fit. Frankly, this is not likely. In most cases a dynamo hub has larger flanges than a non-dynamo hub, so you will need shorter spokes.
There are a lot of spoke calculator programs; some of them are discussed here:
https://bikefat.com/5-best-spoke-length-calculators/