The invention provides a digital lock (100) including at least two magnets. One magnet is a semi hard magnet (310) and the other magnet is a hard magnet (320). The hard magnet (320) is configured to open or close the digital lock (100). The semi hard magnet (310) and the hard magnet (320) are placed adjacent to each other. A change in magnetization polarization of the semi hard magnet (310) is configured to push or pull the hard magnet (320) to open or close the digital lock (100).