def format(self, password, cipher="aes-xts-plain64", keysize=512): """ Formats the device and sets password as the drive's password. """ # Umount lib.umount_bulk(self.string_device) # Try to close try: self.close() except m.CmdError: pass # Ugly as hell m.sexec("echo '%(password)s' | cryptsetup luksFormat --cipher %(cipher)s --key-size %(keysize)s %(device)s" % {"password":password, "device":self.string_device, "cipher":cipher, "keysize":keysize})
def random_fill(self, type=FillQuality.LOW): """ Fills the device with random data. type is an object from the FillQuality enum. It returns the process object to the frontend. """ # Umount lib.umount_bulk(self.string_device) if type == FillQuality.LOW: m.sexec("badblocks -c 10240 -s -w -t random -v %s" % self.string_device) elif type == FillQuality.HIGH: m.sexec("dd if=/dev/urandom of=%s" % self.string_device)
def format(self, password, cipher="aes-xts-plain64", keysize=512): """ Formats the device and sets password as the drive's password. """ # Umount lib.umount_bulk(self.string_device) # Try to close try: self.close() except m.CmdError: pass process = subprocess.Popen( ["cryptsetup", "luksFormat", "--cipher", cipher, "--key-size", str(keysize), self.string_device], stdin=subprocess.PIPE, ) process.communicate(password) process.wait()