The invention provides a digital lock 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 digital lock. The semi hard magnet and the hard magnet are placed adjacent to each other. A change in magnetisation polarisation of the semi hard magnet is configured to push or pull the hard magnet to open or close the digital lock.