The invention provides a magnetic actuator including at least two magnets. One magnet is a semi hard magnet and the other magnet is a hard magnet. The hard magnet is configured to open or close the magnetic actuator. The semi hard magnet and the hard magnet are placed adjacent to each other. A change in magnetization polarization of the semi hard magnet is configured to push or pull the hard magnet to open or close a digital lock realised with the magnetic actuator. The magnetic actuator of the invention can also be used to realise a valve.