privkey_pem = privkey.save_pkcs1()
prikey = open('key.dat','w')
prikey.write(str(privkey_pem))
password = input('введите пароль')
bufferSize = 512 * 1024
pyAesCrypt.encryptFile(str(prikey), str(prikey) + ".aes", password, bufferSize)
prikey.close()
re = self.last_block['index'] + 1
OSError: File "<_io.TextIOWrapper name='key.dat' mode='w' encoding='cp1251'>" was not found.