OpenHashTab icon indicating copy to clipboard operation
OpenHashTab copied to clipboard

Native Linux version? If not, then figure out what is required to get checksum-creation working in WINE?

Open NintendoManiac64 opened this issue 1 year ago • 9 comments

As crazy as it sounds, there doesn't seem to be any native Linux checksum-creation programs that supports the ability to create checksums for the contents of files and folders located in sub-folders.

More info:

  • https://forums.linuxmint.com/viewtopic.php?f=90&t=374983
  • https://forum.winehq.org/viewtopic.php?p=138894

(as referenced in the first forum thread, I'm a user of Linux Mint which is one of those "baby's first Linux" type of distros which itself can tested easily enough via a virtual machine or booting its live ISO via something like ventoy. If you aren't familiar with WINE, then it's easy enough to install on Linux Mint via this guide on the winehq.org wiki

NintendoManiac64 avatar Dec 17 '22 10:12 NintendoManiac64

you can try the standalone mode with

rundll32 OpenHashTab.dll,StandaloneEntry <stuff to hash>

proper shell extension is probably impossible, Wine misses most plumbing around that.

additionally, i have plans on rewriting the too bad parts to use the NT api, as dealing with paths on win32 is simply horrible. Historically, Wine had terrible support for that

namazso avatar Dec 17 '22 11:12 namazso

there doesn't seem to be any native Linux checksum-creation programs that supports the ability to create checksums for the contents of files and folders located in sub-folders.

Most Linux utilities work by doing one thing really well and give you, the user, the ability to do string them together to accomplish powerful things. This command uses the excellent find utility together with sha256sum to hash all files in a given directory (my-directory) and write the output to a file named my-directory.sha256.

sha256sum $(find my-directory) > my-directory.sha256

You can then check the contents by running:

sha256sum --check my-directory.sha256

(find has a lot of options for filtering files, and you can read the find manual at the CLI by running man find. All options you specify would go inside the parentheses of the $(find ... ) part of the command, above.)

Hope that helps!

@namazso You can close this if you have no plans to support Linux / WINE.

kurtmckee avatar Jun 06 '23 19:06 kurtmckee

Hope that helps!

At least on my copy of Linux Mint 20.3 Xfce with kernel 5.15.0-72, It doesn't work if any of the sub-folders have spaces in their name.

(I didn't test the situation of if the sub-folders don't have spaces because, if it doesn't work with spaces, then it's a complete non-starter for me anyway)

NintendoManiac64 avatar Jun 06 '23 20:06 NintendoManiac64

Ah, yes, that's true. The filenames need to be quoted, so rather than dumping the output of find directly to the command line without quotes, the following will run sha256sum for each file with quotes around the filename:

find my-directory | while read filename; do sha256sum "$filename" >> my-directory.sha256; done
  • find my-directory will find all files in the given directory
  • while read filename will read each line of find's output and store it in a variable named "filename"
  • sha256sum "$filename" >> my-directory.sha256 will calculate the checksum just for that one file and append (not overwrite!) the result to a file named my-directory.sha256.

kurtmckee avatar Jun 06 '23 20:06 kurtmckee

@kurtmckee that will break for filenames with newlines. you should be using find's -print0 and xargs -0. Note that the former is a GNU extension. The task is just plain impossible in standard POSIX. I think that tells about the quality of POSIX more than anything.

namazso avatar Jun 06 '23 20:06 namazso

that will break for filenames with newlines

Yikes, I didn't know that. That's a great callout! I'm sure that such filenames would result in a corrupt checksum file anyway, so hopefully what's posted above will be sufficient to unblock @NintendoManiac64's needs, even if it's imperfect.

kurtmckee avatar Jun 06 '23 20:06 kurtmckee

I'm sure that such filenames would result in a corrupt checksum file anyway

Not necessarily! You can use it to make up completely fake entries, turning a fun bug into a security issue if you ever run it against untrusted input. But I agree, sanitizing filenames would probably be a step before this, because it surely won't produce correct input with files that have newlines in name.

Though using a POSIX shell with some untrusted input and trying to have any semblance of security is just a futile effort.

namazso avatar Jun 06 '23 20:06 namazso

The only thing is that one of the main reasons I'm using a "baby's first Linux" distro is that, even though I know how to use a terminal, commands are just not something that I am good at remembering at all.

So even if your command works, it's way too long for me to ever be able to conveniently use it without having to also look up a reminder on what the command is (heck I just had to do this today just to remember the uname -r command to check my kernel version)

Therefore I'm probably going to continue using a combination of HashCheck Shell Extension (for reading checksums) and ExactFile (for creating checksums), both via Wine, for general use.

...though that still doesn't solve the issue that ExactFile is terribly slow if dealing with hundreds of thousands of files (5 hours for 264 thousand files totalling 400GB while HashCheck Shell Extension on Windows does it in like 30 minutes), though in theory ExactFile might be just as fast if you have a 16+ thread CPU rather than my 4.5GHz dual-core Haswell that's only fast at single-threading, but even then ExactFile will straight-up crash at some point around 2 million files even on native Windows let alone Wine (easily reached by simply trying to hash your / partition even if it's only using 30GB).

I'd use HashCheck Shell Extension for both but, as I mention on the Wine forums, there's no way to access its checksum-creation function in Wine.

 

Kind of off-topic ramble

Thing is, I'm one of those weirdos that have exceptionally good spacial memory (and, yes, this was even verified via psychiatric testing years ago) whereby I can remember the content of a file and then remember the general location of it even if its like 5 sub-folders deep amongst many other files and folders, yet have absolutely no idea what its filename is.

Needless to say, abstract things just... don't stay with me. This is also why I'm using Linux Mint and not anything based on GNOME; GNOME's search-based focus works terribly with the way my memory works, and it's also likely why I have absolutely no coding ability whatsoever despite being extremely savvy regarding PC hardware (e.g. successfully delidding four CPUs with nothing but a razor blade).

Amusingly, Linux's config-file-ness of everything works quite well with this extreme spacial memory of mine since I'll typically remember their general locations and even the general position within the conf file itself where a corresponding configuration is located, but I usually won't remember the name of the file or corresponding configuration argument within the file until I actually see it.

NintendoManiac64 avatar Jun 06 '23 20:06 NintendoManiac64

I looked for a native Linux checksum application years ago. What I did find was Double Commander. It is a file manager but does have a good checksum function built in. I've been using it for years without incident. It is also updated regularly.

Unfortunately I have not come across a standalone GUI-based checksum program for Linux, so far. There doesn't appear to be too many for Windows either, that are maintained well.

Here is the link to Double Commander... https://doublecmd.sourceforge.io

TeslaMagic avatar Jul 17 '23 23:07 TeslaMagic