shijimasoft / cia-unix

Decrypt CIA/3DS roms in UNIX environments (Linux and macOS)
Apache License 2.0
111 stars 14 forks source link

Any plan to make this tools work for Python 3.0+ #4

Closed orklann closed 2 years ago

orklann commented 2 years ago

It took me some effort to make cia-unix work on Ubuntu 22.04 with Python2. It would be nice to have it work for Python3 since Python2 is too old, and maybe later we will not run Python 2 at all.

shijimasoft commented 2 years ago

I would like to remove Python 2.7 (as well as PyCrypto) completely from dependencies list, it would be better if the module "decrypt.py" was written in Rust/C++, but I don’t have much time to do it πŸ˜”

Atem18 commented 2 years ago

Hi @orklann and @shijimasoft, I can confirm you that instead of pycrypto, you can use https://github.com/Legrandin/pycryptodome .

It's a drop-in for pycrypto and works for Python3. So it's just a matter of pip install pycryptodome instead of pycrypto.

shijimasoft commented 2 years ago

Hello @Atem18, did you changed some features or methods in decrypt.py? The script should include some python2 things, that must be adjusted for python3

I looked at pycryptodome and I noticed that APIs are the same as pycrypto. Thank you for bringing this to us! 😁

Atem18 commented 2 years ago

@shijimasoft Indeed, there are errors about the str and bytes like:

if magic == 'NSCD'

should become

if magic == b'NSCD'

And a few things that should not be too hard to fix as it's seems that it's mostly about string representation that changed between python 2 and 3.

shijimasoft commented 2 years ago

@Atem18, if you have time to do it, could you commit (with a PR) the new python3 changes? I can create a new experimental branch, and merge it after some tests.

I would really appreciate it 😊

Atem18 commented 2 years ago

@shijimasoft For sure yes, I can try.

shijimasoft commented 2 years ago

Hello @orklann! I recently released a new "experimental" version of cia-unix that supports python3. Now, I've tested it with few roms, please let me know if it works with yours 😁

You can find the experimental branch here.

Note You must install pycryptodome as python3 dependency and build cia-unix from source

shijimasoft commented 2 years ago

I will leave the issue open while the experimental version has been tested

shijimasoft commented 2 years ago

@Atem18 thank you again for your PR ❀️

Atem18 commented 2 years ago

@shijimasoft Thanks to you for your support !

Also do note that I tested with another rom and Citra is still crashing. With which roms did you do your tests ?

Thanks a lot in advance.

shijimasoft commented 2 years ago

@Atem18 I tried Culdcept Revolt (EUR) and Tetris Ultimate (US). They worked smoothly with citra

Atem18 commented 2 years ago

@shijimasoft I tried and they also crash. Which OS and citra version are you testing it ?

shijimasoft commented 2 years ago

I have tested it on macOS (Intel) with the latest citra nightly build

Atem18 commented 2 years ago

@shijimasoft Me too, so I don't understand what is wrong...

shijimasoft commented 2 years ago

@Atem18 try to uninstall citra with appcleaner (it will remove also citra caches and hidden files) and reinstall it, let me know if changed something

Atem18 commented 2 years ago

@shijimasoft Same issue on Linux so maybe I am missing something somewhere.

shijimasoft commented 2 years ago

It is very strange. Anyway, I will release the preview build (with python3 support) in the next few days, so it will be possible to get more feedback

skabber commented 2 years ago

I have also tried building and running the experimental branch on Arch Linux (Steam Deck) and am having some issues.

  1. cia-unix complains that the decrypt.py file is not present. As far as I can tell, it is.
  2. The resulting decrypted ROM crashes Citra (Nightly 1772)

(deck@steamdeck cia-unix)$ crystal build cia-unix.cr --release --no-debug
(deck@steamdeck cia-unix)$ ./cia-unix 
which: no decrypt.py in (/home/deck/.linuxbrew/bin:/home/deck/.linuxbrew/sbin:/home/deck/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/var/lib/flatpak/exports/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl)
Decrypting: TLOZALBWEU.3ds...
Building decrypted TLOZALBWEU 3DS...
Decryption completed

Removing cache...
Log saved
(deck@steamdeck cia-unix)$ ls
build.sh  cia-unix  cia-unix.cr  ctrtool  decrypt.py  dltools.sh  LICENSE  makerom  README.md  TLOZALBWEU.3ds  TLOZALBWEU-decrypted.3ds
shijimasoft commented 2 years ago

@skabber I just committed a fix for this error (https://github.com/shijimasoft/cia-unix/commit/9609400373251d1c82fc96cb653a926212adbf20), please try to compile the updated code and let me know if it worked, thank you πŸ˜„

shijimasoft commented 2 years ago

Also, I will close this issue, if you have any other problems, please open a new one.