开发者

how to deal with a CP-1252 encoded password under linux?

开发者 https://www.devze.com 2022-12-27 03:57 出处:网络
I have the following problem. I need to create a zip file under linux with a password provided by another party that is encoded with CP-1252. What I have tried is changing the encoding of this passwor

I have the following problem. I need to create a zip file under linux with a password provided by another party that is encoded with CP-1252. What I have tried is changing the encoding of this password to UTF-8. Then I made a zipfile protected with this utf-8 encoded password. However the file can not be unzipped in windows with the original password that is CP-1252 encoded.

开发者_运维问答Regards,

Gordon


Handling a ZIP file with any content (filenames or passwords) that isn't ASCII is fraught with difficulty and best avoided. You should do everything you can to limit the allowable passwords to plain ASCII, which will work anywhere.

Each OS will treat the bytes as being in their own system default encoding, which is likely (but not certain) to be UTF-8 in recent Linuxen, UTF-8 in OS X, and never UTF-8 in Windows. Even if you create a ZIP file with a non-ASCII password encoded in cp1252, it will only be readable on Western European Windows installs. And some ZIP tools behave differently still (eg. the nautilus zip decoder seems to use ISO-8859-1 for passwords even when it is using UTF-8 for filenames). The whole thing is a broken mess.

You can create ZIP files with cp1252 passwords in Linux. What tool are you currently using to create passworded files? The command line zip tool just accepts bytes and doesn't care what encoding they're in, so to ensure any non-ASCII characters you are typing at the keyboard when it prompts you for a password are in cp1252, you should set the encoding of your terminal to cp1252. For the GNOME default ‘Terminal’ this can be done from Terminal->Set Character Encoding->Windows-1252 (you may have to Add/Remove this encoding if it is not listed).


Have a look at 7z project, it worked for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消