Sublime Forum

Hex Viewer (a hex viewer and editor)

#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

#29
  1. I assure you it does work.

  2. This is not the place to get help, please use the Repo’s issue tracker github.com/facelessuser/HexViewer/issues; I don’t get notifications through the forum, and there is no way to track the issue here.

  3. When you create an issue on the Github repo, give me info I can use to actually help you.

  • OS you are using
  • Sublime Text build number
  • When you start sublime, if you scroll through the log, do you see console errors from HexViewer? Maybe something is isn’t loaded proper. Sometimes Package Control will do goofy things like install an ST2 version of a plugin on an ST3 machine or vice versa.
  • Did you restart after installing the package? Some times this is important as not all modules may have gotten loaded proper during installation.
  • Are you sure you have the latest version from Package Control. Uninstalling and reinstalling will usually ensure you have the latest (restart after installation to make sure things are loaded proper).
  • How do you understand what you are trying to do works? And what are the steps you are doing to get it work? That way I can follow your thought process and see how you might be off. I need to be able to reproduce your problem or I can’t help.

The documentation explains how this all works:

[quote] Invoking this command will take the currently selected bytes on a line and display them in an input panel. They can then be modified and submitted to replace the original bytes. Strings can also be used by using the “s:” prefix followed by the equivalent ASCII characters that are to replace the selected bytes.
[/quote]

So, first make sure you have some bytes selected (only bytes); whether it is their ascii form or hex form, it does not matter, as selecting one also selects the other. Invoke the edit command and the an input panel will pop up at the bottom of the view showing the hex representation in the input box. You can change the bytes, but the amount of bytes in the panel must match the original byte number when pressing enter. You are editing the bytes in place; you cannot insert more or delete, only change. If you want to, you can instead modify the characters in the ASCII domain (no unicode). Simply prefix your input with “s:” and type ASCII chars instead; again the ASCII chars must equal the original byte count.

If you want further help, create an issue on github.

0 Likes

#30

Keep in mind if you are using ST2, support ST2 variants of my plugins are no longer actively supported. I would upgrade to ST3. I just don’t have time to support two different versions of all my plugins.

0 Likes