Sublime Forum

Hex Viewer (a hex viewer and editor)

#9

#Version 0.6

  • Commands accessible from menu Tools > Packages > Hex Viewer (thanks to jsadeli)
  • Fix checksum not responding to settings change
  • Add CRC32 and ADLER32 hash algorithms for checksums

Somewhere along the lines I broke checksums responding to the settings file for the algorithm; this is now fixed. Also, I added some obvious checksumming algorithms that were not there before: CRC32 and ADLER32.

That should be all of the major things I wanted to get done. Let me know if any bugs turn up or you have any feature ideas.

0 Likes

#10

Got some new checksum hashes in: sha, mdc2, md4, ripemd160.

I already had the ones from hashlib, and zlib, but I pulled in the ones that are included with openssl. These may differ on some systems, so I currently check if they are available and only include them if they are. If I find some other ones that are available that I am not including, I will add those.

I was so close to getting whirlpool algorithm in here. The algorithm is public domain, and I had it working, but I could not get it working yet when the data is chunked; the hash comes out wrong. So, to get the right hash currently, the entire file’s data is loaded into one big buffer and the hash is applied on that, and since it is 100% python, it takes a long time on big files…but it worked. Due to this, I have not included it. If I can deconstruct the algorithm enough to figure out how the get chunked data to evaluate the same, I will include it later.

Since the current supported hashes could vary on certain systems, when the checksum command or shortcut is invoked, I will now show a quickpanel populated with the valid hashes that can be used for selection.

0 Likes

#11

Got whirlpool hash working with chunking. I got the python port of the hash from this one site, and it looked pretty exact with the C source. The guy who did the python port I guess assumed that the adding to the hash function worked the same as update in hashlib, so he wrapped similar, but this just wasn’t the case. With a little analyzation, I was able to adapt the algorithm to mimic hashlib’s update and allow for proper hashing of chunked data. Now the hash comes out correct whether chunked or not.

It works pretty good checksumming the average source code files, but if you try this on a 3MB file, it will take a bit because it is straight Python, and the algorithm is fairly complex. Because of this, I went ahead and added checksum threading. So if you are checksumming a really large file, you will see the progress in the status bar. If you want to cancel, just run the checksum command again, and the current thread will be canceled.

I am only adding these hashes because I am finding it fun figuring these out. I may allow in the future to tap in to these functions to generate hashes from selected strings etc, which is useful if you need to generate hashes in your source code. Maybe I will split out the hash code into its own plugin; we will see.

I will probably commit the whirlpool hash along with the checksum threading tomorrow.

0 Likes

#12

I was going to port it myself, but someone already ported Tiger192 hash algorithm. Again, it wasn’t allowing chunking, but I added that in and wrapped it like hashlib. So, I have now postponed the commit till tomorrow. I will commit both whirlpool and tiger192 hash for checksumming, and I think I am done playing with hashes for now.

I may add in some kind of command that will allow you to enter a string and return your desired hash. It isn’t really directly related to hex editing, but since I spend this time adding in all of these hashes, might as well give access to them.

0 Likes

#13

#Version 0.8

  • New hash algorithms: Whirlpool and Tiger-192
  • Checksums are now threaded
  • Exposed new command to tap into hashes called “Hex Viewer: Generate Hash”
  • Rework logic to determine which hashes are available

So the new hashes are added, and I added a new command to generate a hash from a string at any time you need. You do not have to be in hex view to do this; as a matter fact, it really has nothing to do with the hex viewer, I am just tapping into the hash framework I put in because I think it might be useful to some.

0 Likes

#14

Missed some commas in windows and linux keymaps…I guess you can tell I have been testing in Mac recently :blush: .
Apparently, it was reported to me this small mistake, prevented ST2 from starting in Windows. It kind of surprises me that this kind of error could take down the entire editor in windows, but I shouldn’t have missed those commas either.

This should be resolved now.

0 Likes

#15

Now that I am done goofing off with hashes, I added a useful feature.

I just added auto opening of specified binary files in Hex Viewer. If you directly open a file, select in the side bar, or select it via “Go To Anything”, it will open your will open files defined by patterns in the setting file automatically in Hex Viewer.

Direct opening should open without delay, but I have defined a 2 second delay for previews of binary files; this prevents opening a Hex View tab if you are just passing a binary file in “Go To Anything”. If the first “Go To Anything” selection is a binary file, if you linger for more than two seconds, a Hex View tab will be opened (you can increase this delay via the settings file). After you start moving around in the “Go To Anything” menu, you know longer have to worry about lingering.

Currently it is disabled by default. I am going to wait and do more testing before I enable it by default, but feel free to try it out.

0 Likes

#16

I may have spoken prematurely. I think I have the logic worked out now. I removed the delay. You should be able work as normal without fear of accidentally triggering Hex View. Previews should now function as they always have, and when the file is actually opened, Hex View Auto Open will kick in. Try it out and let me know what you think. Just enable it in the settings file, and define your file patterns.

0 Likes

#17

Version 1.5

  • Allow the hashing of current selection(s). Multiselect regions’s content will be combined and evaluated together
  • Update hash progress quicker
  • Chunk hashes entered in the input panel in case very large amounts of data are pasted in

Decided to add the ability to select text, and hash it. It handles multi-regions too. It just adds the regions together in the order they come in the file and hashes them as one entry.

0 Likes

#18

Version 1.6

  • Report Tiger-192 as big endian as most hashing programs do

Was always a little curious why tiger hash seemed to give me valid results, but differed from every hash program I have compared it to. The endian convention I was using was different from what everyone else used…go figure. The hash was still completely valid, and matched the tiger hash web site results, but every hash tool in the world uses the other convention. Well, now I match them as well to avoid confusion. :smile:

0 Likes

#19

Version 1.7

  • More responsive highlighting
  • Turn off gutter icons for highlighting by default (does not seen needed)
  • Convert tabs to spaces in settings file

Pulling in the more responsive highlighting from BracketHighlighter.

0 Likes

#20

Would it be possible to have the hex editor open AND be positioned to where the cursor or selection currently is? E.g. Say I put the cursor at the end of a line, then open the Hex Viewer, it should open to that same spot at the end of the line (so that I can view 0d 0a).

Currently it always opens with the cursor at the start of the file.

0 Likes

#21

[quote=“Callidus”]Would it be possible to have the hex editor open AND be positioned to where the cursor or selection currently is? E.g. Say I put the cursor at the end of a line, then open the Hex Viewer, it should open to that same spot at the end of the line (so that I can view 0d 0a).

Currently it always opens with the cursor at the start of the file.[/quote]

I don’t know…maybe. The view that ST2 gives of the text is a modified representation of the actual file. The hex view is a raw representation of the file. It may not be easy to analyze the ST2 buffer and find the correct offset into the binary buffer of the file.

0 Likes

#22

I’m not sure if I’m doing the wrong thing. I have tried installing Hex Viewer both manually and using package control. I have restarted ST2. The toggle hex option does appear, but it doesn’t appear to do anything. In case it helps: I’m using ST 2.0.2, OS X 10.7.5 and Python version 2.7.1.

Any help much appreciated.

Thanks.

0 Likes

#23

I will try upgrading my ST2 (I am currently using ST3 on OSX 10.8). Do you see any errors in the console? How big a file are you trying to view as hex? Details, details, I need the details :smile:.

0 Likes

#24

Well, this is strange. I went back to check the console to see if an error appeared but this time the toggling worked. Thank you for your quick reply anyway.

0 Likes

#25

No worries. Glad you got it working.

0 Likes

#26

Hey, how the heck do you actually edit anything? I have hex view loaded on this file using the command palette command, “Hex Viewer: Toggle Hex View” and I’m pressing keys with the part I want to edit selected and nothing is happening. Could you please write something about the basic usage of this arcane addon?

0 Likes

#27

Read here: github.com/facelessuser/HexView … edit-panel.

0 Likes

#28

Oh, I should have also mentioned that “Hex Viewer: Show Hex Edit Panel” does absolutely nothing. I hadn’t read that part of what you linked me, but I had tried “Hex Viewer: Show Hex Edit Panel”. It didn’t bring up anything. There was no reaction from the program, despite trying multiple times; not even an error. I then assumed that I was already viewing the “hex edit panel”. I scoured the screen for such a thing, and concluded that the uneditable area I was already viewing was the supposed “Hex Edit Panel”, and that it wasn’t working for some other reason. I was wrong there, but there was another bug, I suppose. How do I actually make the “Hex Edit Panel” appear if using “Hex Viewer: Show Hex Edit Panel” from the command palette does nothing?

0 Likes