{"action":"closed","issue":{"url":"https://api.github.com/repos/pyinstaller/pyinstaller/issues/3531","repository_url":"https://api.github.com/repos/pyinstaller/pyinstaller","labels_url":"https://api.github.com/repos/pyinstaller/pyinstaller/issues/3531/labels{/name}","comments_url":"https://api.github.com/repos/pyinstaller/pyinstaller/issues/3531/comments","events_url":"https://api.github.com/repos/pyinstaller/pyinstaller/issues/3531/events","html_url":"https://github.com/pyinstaller/pyinstaller/issues/3531","id":324740323,"number":3531,"title":"Encryption on Python 3 / Windows","user":{"login":"oberstet","id":233340,"avatar_url":"https://avatars3.githubusercontent.com/u/233340?v=4","gravatar_id":"","url":"https://api.github.com/users/oberstet","html_url":"https://github.com/oberstet","followers_url":"https://api.github.com/users/oberstet/followers","following_url":"https://api.github.com/users/oberstet/following{/other_user}","gists_url":"https://api.github.com/users/oberstet/gists{/gist_id}","starred_url":"https://api.github.com/users/oberstet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oberstet/subscriptions","organizations_url":"https://api.github.com/users/oberstet/orgs","repos_url":"https://api.github.com/users/oberstet/repos","events_url":"https://api.github.com/users/oberstet/events{/privacy}","received_events_url":"https://api.github.com/users/oberstet/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-05-20T20:32:44Z","updated_at":"2018-05-28T17:12:50Z","closed_at":"2018-05-28T17:12:50Z","author_association":"NONE","body":"I'm not entirely sure if this is an issue you consider within the scope of PyInstaller at all - so feel free to close! I'll just collect my findings.\r\n\r\nSo I want to use `--key` on y Windows 10 x64 build host with CPython 3.6, but installing PyCrypto fails, so I install https://github.com/Legrandin/pycryptodome\r\n\r\nThis claims to be compatible, and the issue I run into is that PyInstaller instantiates a AES key from a `str` (which is even asserted https://github.com/pyinstaller/pyinstaller/blob/develop/PyInstaller/archive/pyz_crypto.py#L46), which is Unicode under Python 3, not bytes what AES expects.\r\n\r\nIs `--key` supposed to work on Python 3 on Windows?\r\n\r\n> I am aware that \"encryption\" is considered an \"enterprise feature\", in which case I am happy to hear about options;)\r\n\r\n```\r\n28716 INFO: checking PYZ\r\n28716 INFO: Building PYZ because out00-PYZ.toc is non existent\r\n28716 INFO: Building PYZ (ZlibArchive) C:\\projects\\crossbarfx\\build\\crossbarfx\\out00-PYZ.pyz\r\nTraceback (most recent call last):\r\n  File \"C:\\Python36-x64\\Scripts\\pyinstaller-script.py\", line 11, in <module>\r\n    load_entry_point('PyInstaller==3.3.1', 'console_scripts', 'pyinstaller')()\r\n  File \"c:\\python36-x64\\lib\\site-packages\\PyInstaller\\__main__.py\", line 94, in run\r\n    run_build(pyi_config, spec_file, **vars(args))\r\n  File \"c:\\python36-x64\\lib\\site-packages\\PyInstaller\\__main__.py\", line 46, in run_build\r\n    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)\r\n  File \"c:\\python36-x64\\lib\\site-packages\\PyInstaller\\building\\build_main.py\", line 791, in main\r\n    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))\r\n  File \"c:\\python36-x64\\lib\\site-packages\\PyInstaller\\building\\build_main.py\", line 737, in build\r\n    exec(text, spec_namespace)\r\n  File \"<string>\", line 18, in <module>\r\n  File \"c:\\python36-x64\\lib\\site-packages\\PyInstaller\\building\\api.py\", line 98, in __init__\r\n    self.__postinit__()\r\n  File \"c:\\python36-x64\\lib\\site-packages\\PyInstaller\\building\\datastruct.py\", line 161, in __postinit__\r\n    self.assemble()\r\n  File \"c:\\python36-x64\\lib\\site-packages\\PyInstaller\\building\\api.py\", line 133, in assemble\r\n    pyz = ZlibArchiveWriter(self.name, toc, code_dict=self.code_dict, cipher=self.cipher)\r\n  File \"c:\\python36-x64\\lib\\site-packages\\PyInstaller\\archive\\writers.py\", line 184, in __init__\r\n    super(ZlibArchiveWriter, self).__init__(archive_path, logical_toc)\r\n  File \"c:\\python36-x64\\lib\\site-packages\\PyInstaller\\archive\\writers.py\", line 59, in __init__\r\n    self._add_from_table_of_contents(logical_toc)\r\n  File \"c:\\python36-x64\\lib\\site-packages\\PyInstaller\\archive\\writers.py\", line 84, in _add_from_table_of_contents\r\n    self.add(toc_entry)  # The guts of the archive.\r\n  File \"c:\\python36-x64\\lib\\site-packages\\PyInstaller\\archive\\writers.py\", line 213, in add\r\n    obj = self.cipher.encrypt(obj)\r\n  File \"c:\\python36-x64\\lib\\site-packages\\PyInstaller\\archive\\pyz_crypto.py\", line 58, in encrypt\r\n    return iv + self.__create_cipher(iv).encrypt(data)\r\n  File \"c:\\python36-x64\\lib\\site-packages\\PyInstaller\\archive\\pyz_crypto.py\", line 64, in __create_cipher\r\n    return self._aesmod.new(self.key, self._aesmod.MODE_CFB, iv)\r\n  File \"c:\\python36-x64\\lib\\site-packages\\Crypto\\Cipher\\AES.py\", line 200, in new\r\n    return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)\r\n  File \"c:\\python36-x64\\lib\\site-packages\\Crypto\\Cipher\\__init__.py\", line 55, in _create_cipher\r\n    return modes[mode](factory, **kwargs)\r\n  File \"c:\\python36-x64\\lib\\site-packages\\Crypto\\Cipher\\_mode_cfb.py\", line 230, in _create_cfb_cipher\r\n    cipher_state = factory._create_base_cipher(kwargs)\r\n  File \"c:\\python36-x64\\lib\\site-packages\\Crypto\\Cipher\\AES.py\", line 100, in _create_base_cipher\r\n    result = start_operation(c_uint8_ptr(key),\r\n  File \"c:\\python36-x64\\lib\\site-packages\\Crypto\\Util\\_raw_api.py\", line 109, in c_uint8_ptr\r\n    raise TypeError(\"Object type %s cannot be passed to C code\" % type(data))\r\nTypeError: Object type <class 'str'> cannot be passed to C code\r\nCommand exited with code 1\r\ndate\r\nSun May 20 13:07:13 PDT 2018\r\n```"}}
{"actor":{"display_login":"htgoebel"}}