My Notepad++ binhex plugin



  • hi All,
    I have developed a notedpad++ binhex plugin for manipulating with binary/hex string with functions below

    • bin2hex/hex2bin - conversion between hex and binary text
    • bin_invert/hex_invert - bit inversion for bin/hex text (0b1010 -> 0b0101)
    • reverse - text reverse (abcd -> dcba)
    • hex_shift - shift left/right for hex values, lose the shift out bit
    • hex_rotate - rotate left/right for hex values, lsb become msb and vice versa
    • grouping_2/4/8/16 - grouping hex/bin string to 2/4/8/16 char

    Refer github link below for details
    https://github.com/skycc86/npp_binhex_plugin

    Its just a simple plugin that i used quite a lot, hope someone might feel it handy :)
    Its available for both win32 and x64 version.



  • See https://github.com/bruderstein/nppPluginManager how to add it to the plugin manager.
    Typically on github the source code is not added as zip, but directly. Additionally it is possible in this case to add an appveyor configuration for continuous integration builds. Releases could be done under https://github.com/skycc86/npp_binhex_plugin/releases instead of adding the binaries to the master.
    PluginManager needs the binaries as zip.





  • thanks @chcg , i have merge your pull request and just made a binary release in github
    https://github.com/skycc86/npp_binhex_plugin/releases

    will find out how to add it into plugin manager next.

    i have check on the plugintemplate, i am using the latest release v3.1, i just download the template from github master branch recently :)



  • Ah, the spirit of C++98… It’s like when I was younger, I feel nostalgia. No abstractions over abstractions over abstractions that overcomplicate the code understanding significantly - and in fact are used only in the name of flexibility that no one really understands at the end…
    Is it expected to work with UTF-8 text that contains non-Latin characters, by the way?



  • Sorry, my wording might be confusing on the binary hex conversion, its actually mean binary base to hexadecimal base string value conversion.

    For eg, 0xa5 -> 0b10100101

    So,it will not work with latin char, maybe you are looking for hex editor plugin



  • Available from PluginManager on the dev plugin list. For x64 see https://github.com/bruderstein/npp-plugins-x64/commit/451f3bb9e4041de14cb6a2a99e91ae46725ff28d. x86 is already available.



  • cool, justed tested it out with plugin manager, it works, thanks @chcg



  • I have a big problem with your plugin, so I had to uninstall it. It does some work on Ctrl-Shift-Left/Right. This is a Windows global shortcut reserved for moving one word left or right while selecting. I use it quite a lot and I was mystified when not only it did not work, but it was changing the selected text (even when it was NOT valid hexadecimal, like “Download”). I only installed it because I was looking for a hex editor, so uninstalling it does not impact me, but I thought I would tell you so you can address the problem for people who want to use it.

    Cheers!



  • @Costin-Manda See https://github.com/skycc86/npp_binhex_plugin/issues/3. Maybe you want to contribute there.



  • Hello, @skycc-lim, @costin-manda, and All

    I tested your plugin features and everything works as expected ! Great :-))

    Notes :

    • When you speak of HEX shift and HEX rotate, I think that you should write, strictly, BIN shift and BIN rotate !

    • To avoid shortcut conflicts, mentioned by @costin-manda, I personally use the < and > symbols, instead. Note, that, on my French keyboard, these two symbols are obtained with the same key, as shown here :

    http://ascii-table.com/keyboard.php/189

    For people, having a key for the < symbol and an other key for the > symbol, on their keyboard, as the US one, for instance, shortcuts would be more simple to create !

    • On the other hand, to avoid the shortcut conflict with the native Select All Between Matching Braces option of N++, I changed the B with the N letter ( from word biN ) and I also changed the hex2bin shortcut, accordingly !

    So, may be, @skycc-lim, it would judicious to, globally, change the BinHex menu, as below :

                       BEFORE                                                      AFTER
                      ¯¯¯¯¯¯                                                      ¯¯¯¯¯
    				 
    --------------------------------------------                --------------------------------------------
      bin2hex          Ctrl + Shift + H                           bin2Hex          Ctrl + Shift + H
      hex2bin          Ctrl + Shift + B                           hex2biN          Ctrl + Shift + N
      bin_invert       Ctrl + Alt + B                             Hex_invert       Ctrl + Alt + H      <-- Swapped
      hex_invert       Ctrl + Alt + H                             biN_invert       Ctrl + Alt + N      <-- Swapped
      reverse          Ctrl + R                                   Reverse          Ctrl + R
    --------------------------------------------                --------------------------------------------
      hex_shift >>     Ctrl + Shift + Right                       bin_shift >>     Ctrl + Shift + <>
      hex_shift <<     Ctrl + Shift + Left                        bin_shift <<     Ctrl + <>
      hex_rotate >>    Ctrl + Alt + Right                         bin_rotate >>    Ctrl + Alt + Shift + <>
      hex_rotate <<    Ctrl + Alt + Left                          bin_rotate <<    Ctrl + Alt + <>
    --------------------------------------------                --------------------------------------------
      grouping_2       Ctrl + Alt + 2                             grouping_2       Ctrl + Alt + 2
      grouping_4       Ctrl + Alt + 4                             grouping_4       Ctrl + Alt + 4
      grouping_8       Ctrl + Alt + 8                             grouping_8       Ctrl + Alt + 8
      grouping_16      Ctrl + Alt + 6                             grouping_16      Ctrl + Alt + 6
      ungroup          Ctrl+  Alt + 1                             ungroup          Ctrl+  Alt + 1  
    --------------------------------------------                --------------------------------------------
      incremental search                                          incremental search
      move to other view                                          move to other view
    --------------------------------------------                --------------------------------------------
      help                                                        help
    --------------------------------------------                --------------------------------------------
    

    Just a suggestion, of course ;-))


    Now, for people, not acquainted to bits manipulation, here are, below, some explanations, on the different commands of the BinHex plugin :

    In this summary, I use, in all the examples, the hexadecimal number f2a58b0437fc5e8223a6bd401cff90a7 ( two Q-words )

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
      ORIGINAL Number N ( 2 Q-words )  =  f2a58b0437fc5e8223a6bd401cff90a7
    
    
      Hex2Bin  ( Replace each HEX symbol with its 4-Bits BINARY equivalent )  =>  11110010101001011000101100000100001101111111110001011110100000100010001110100110101111010100000000011100111111111001000010100111
    
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
      ORIGINAL Number N ( 128 bits )  =  11110010101001011000101100000100001101111111110001011110100000100010001110100110101111010100000000011100111111111001000010100111
    
    
      Bin2Hex  ( Replace each group of 4 BIN symbols with its HEX equivalent )  =>  f2a58b0437fc5e8223a6bd401cff90a7
    
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
      ORIGINAL Number N ( 2 Q-words )  =  f2a58b0437fc5e8223a6bd401cff90a7
    
      As :
    
      Bin-Invert of 0 (0000)  =  F  (1111)    Bin-Invert of 4 (0100)  =  B  (1011)    Bin-Invert of 8 (1000)  =  7  (0111)    Bin-Invert of C (1100)  =  3  (0011)
      Bin-Invert of 1 (0001)  =  E  (1110)    Bin-Invert of 5 (0101)  =  A  (1010)    Bin-Invert of 9 (1001)  =  6  (0110)    Bin-Invert of D (1101)  =  2  (0010)
      Bin-Invert of 2 (0010)  =  D  (1101)    Bin-Invert of 6 (0110)  =  9  (1001)    Bin-Invert of A (1010)  =  5  (0101)    Bin-Invert of E (1110)  =  1  (0001)
      Bin-Invert of 3 (0011)  =  C  (1100)    Bin-Invert of 7 (0111)  =  8  (1000)    Bin-Invert of B (1011)  =  4  (0100)    Bin-Invert of F (1111)  =  0  (0000)
    
    
      Hex_Invert  =>  0d5a74fbc803a17ddc5942bfe3006f58  —  Strictly,  Bin2Hex (Bin_Invert (Hex2Bin (N)))
    
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
      ORIGINAL Number N ( 2 Q-words )  =  f2a58b0437fc5e8223a6bd401cff90a7
    
    
      Reverse  ( RIGHT to LEFT reading of the HEX string )  =>  7a09ffc104db6a3228e5cf7340b85a2f
    
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
      Hex2Bin + Grouping_4  =>  1111_0010_1010_0101_1000_1011_0000_0100_0011_0111_1111_1100_0101_1110_1000_0010_0010_0011_1010_0110_1011_1101_0100_0000_0001_1100_1111_1111_1001_0000_1010_0111
    
      As MSB = Most Significant Bit  and  LSB = Least Significant Bit :
    
    
      Bin-Shift >>  ( Add 0 as MSB — Shift OUT the LSB )  =>  7952c5821bfe2f4111d35ea00e7fc853
    
      =  0111_1001_0101_0010_1100_0101_1000_0010_0001_1011_1111_1110_0010_1111_0100_0001_0001_0001_1101_0011_0101_1110_1010_0000_0000_1110_0111_1111_1100_1000_0101_0011
    
    
      Bin-Shift <<  ( Shift OUT the MSB — Add 0 as LSB )  =>  e54b16086ff8bd04474d7a8039ff214e
    
      =  1110_0101_0100_1011_0001_0110_0000_1000_0110_1111_1111_1000_1011_1101_0000_0100_0100_0111_0100_1101_0111_1010_1000_0000_0011_1001_1111_1111_0010_0001_0100_1110
    
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
      Hex2Bin + Grouping_4  =>  1111_0010_1010_0101_1000_1011_0000_0100_0011_0111_1111_1100_0101_1110_1000_0010_0010_0011_1010_0110_1011_1101_0100_0000_0001_1100_1111_1111_1001_0000_1010_0111
    
      As MSB = Most Significant Bit  and  LSB = Least Significant Bit :
    
    
      Bin-Rotate >>  ( Move the LSB as the MSB )  =>  f952c5821bfe2f4111d35ea00e7fc853
    
      =  1111_1001_0101_0010_1100_0101_1000_0010_0001_1011_1111_1110_0010_1111_0100_0001_0001_0001_1101_0011_0101_1110_1010_0000_0000_1110_0111_1111_1100_1000_0101_0011
    
      Bin-Rotate <<  ( Move the MSB as the LSB )  =>  e54b16086ff8bd04474d7a8039ff214f
    
      =  1110_0101_0100_1011_0001_0110_0000_1000_0110_1111_1111_1000_1011_1101_0000_0100_0100_0111_0100_1101_0111_1010_1000_0000_0011_1001_1111_1111_0010_0001_0100_1111
    
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
      ORIGINAL Number N ( 2 Q-words )  =  f2a58b0437fc5e8223a6bd401cff90a7
    
      Grouping_2   =>  f2_a5_8b_04_37_fc_5e_82_23_a6_bd_40_1c_ff_90_a7  :   16 Bytes   of  8 bits  ( 128 bits )
                                                                         
      Grouping_4   =>  f2a5_8b04_37fc_5e82_23a6_bd40_1cff_90a7          :    8 Words   of 16 bits  ( 128 bits )
                                                                         
      Grouping_8   =>  f2a58b04_37fc5e82_23a6bd40_1cff90a7              :    4 D-Words of 32 bits  ( 128 bits )
                                                                            
      Grouping_16  =>  f2a58b0437fc5e82_23a6bd401cff90a7                :    2 Q-Words of 64 bits  ( 128 bits )
    
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    

    Best Regards,

    guy038



  • Hi @guy038
    Thanks for your suggestions, i will look into it when i have some time.
    I am quite busy recently

    For the shortcut key mapping,
    User can change this anytime to their preference. The shortcut key can be change as below
    goto Settings -> Shortcut Mapper
    then click on Plugin commands tab on top, then you will see list of plugin and its correspond function and shortcut key
    look for binhex.dll, just click on the shortcut key you wish to change then save it



  • @Skycc-Lim

    I think the shortcuts problem people keep talking about is that you’ve taken over very common key-combinations in your plugin. Sure, people can remap them, but really, why not supply the plugin without these?

    I dislike it when a plugin I’m simply trying out takes over my keycombos assigned to other things. Grr…

    IMO plugins should not set default shortcut keycombos at all. Sure, provide mappable commands, but let the end-user map them as desired.



  • hi @Scott Summer

    this sounds like a good idea, i have just made an release v2.0.0.1
    this removing the default shortcut that clash with npp default shortcut



  • updated pluginmanager with v2.0.0.1



  • hi @chcg ,
    after i try to update my binhex plugin from v2.0.0.0 to v2.0.0.1, the update run successfully, however, under the updates tab from the plugin manager, its still showing current install version as 2.0 and require update. can you help to take a look ?

    binhex plugin is not showing up at the available and installed tab from plugin manager too.



  • Hi @chcg
    please ignore my previous post, i have found the issue, i forgot to change the versioning in the dll, i have fix it and made a new release to overwrite previous release, its still same version v2.0.0.1.

    however plugin manager show it fail to validate the integrity of binhex.dll, i guess might need to update on the new binhex.dll checksum or some integrity check ? can you help ?



  • Done. Updated the md5 sums.


Log in to reply