
    Ziy                        S r SrSSKrSSKr\R                  R                  \R                  R                  \R                  R                  \5      5      5      r	\R                  R                  \R                  R                  \	S5      5      r\\R                  ;  a  \R                  R                  S\5        SSKr\R                  S   S:  a  \rSrOSrS rS	 rS
R                  \" S5       V s/ s H>  n \" \" \" U 5      5      5      S:*  =(       a    U S:  =(       a    \" U 5      =(       d    SPM@     sn 5      rSS jrSS jrSS jrS r\S:X  a  \" 5         ggs  sn f )a  
ezhexviewer.py

A simple hexadecimal viewer based on easygui. It should work on any platform
with Python 2.x or 3.x.

Usage: ezhexviewer.py [file]

Usage in a python application:

    import ezhexviewer
    ezhexviewer.hexview_file(filename)
    ezhexviewer.hexview_data(data)


ezhexviewer project website: http://www.decalage.info/python/ezhexviewer

ezhexviewer is copyright (c) 2012-2019, Philippe Lagadec (http://www.decalage.info)
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

 * Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
z0.54    Nz..   TFc                 F    [        U [        5      (       a  U $ [        U 5      $ )a[  
workaround for ord() to work on characters from a bytes string with
Python 2 and 3. If s is a bytes string, s[i] is a bytes string of
length 1 on Python 2, but it is an integer on Python 3...
xord(c) returns ord(c) if c is a bytes string, or c if it is already
an integer.
:param char: int or bytes of length 1
:return: ord(c) if bytes, c if int
)
isinstanceintord)chars    n/var/www/eduai.edurigo.com/question_generate/ques_gen_env/lib/python3.13/site-packages/oletools/ezhexviewer.pyxordr
   W   s      $4y    c                 F    [         (       a  [        U /5      $ [        U 5      $ )a  
workaround for chr() to return a bytes string of length 1 with
Python 2 and 3. On Python 3, chr returns a unicode string, but
on Python 2 it is a bytes string.
bchr() always returns a bytes string on Python 2+3.
:param x: int
:return: chr(x) as a bytes string
)PYTHON3byteschrxs    r	   bchrr   f   s      w aSz1vr   r                .c           
      n   / n[        S[        U 5      U5       H  nXXA-    nSR                  U Vs/ s H  nS[        U5      -  PM     sn5      nUR	                  [
        5      n[        (       a  UR                  S5      nUR                  SXB-   US-  Xx4-  5        M     SR                  U5      $ s  snf )zp
Returns a hexadecimal dump of a binary string.
length: number of bytes per row.
startindex: index of 1st byte.
r    z%02Xlatin1z%08X   %-*s   %s
r    )	xrangelenjoinr
   	translateFILTERr   decodeappend)	srclength
startindexresultisr   hexa	printables	            r	   hexdump3r*      s     FAs3x(!(Oxx151a$q')156KK'	7!((2I*alF1Hd-VVW ) 776? 6s   B2
c                 B    [        XUS9n[        R                  " XUS9  g )N)r#   r$   )msgtitletext)r*   easyguicodebox)datar,   r-   r#   r$   hexs         r	   hexview_datar3      s    
4:
>COOs3r   c                 N    [        U S5      R                  5       n[        XQX#US9  g )Nrb)r,   r-   r#   r$   )openreadr3   )filenamer,   r-   r#   r$   r1   s         r	   hexview_filer9      s#    $$$&DezRr   c                       [         R                  S   n U (       a   [	        U SU -  S9  g g !   [        R                  " 5       n  N0= f!   [        R
                  " SSS9   g = f)N   zFile: %s)r,   zError:ezhexviewer)r,   r-   )sysargvr/   fileopenboxr9   exceptionbox)r8   s    r	   mainrA      s_    )88A; 	DzH'<= )&&(	D  X]Cs   , A AA!__main__)   r   )r   r<      r   )__doc____version__r=   ospathnormpathabspathdirname__file___thismodule_dirr   _parent_dirinsertr/   version_inforanger   r   r
   r   r   reprr   r*   r3   r9   rA   __name__r   s   0r	   <module>rT      s@  'f   ''""277??277??83L#MNggrww||OTBCchhHHOOA{#  A! FGG0 
TYZ]T^_T^qCT!W&)5agB47JdJT^_	`,4
S	D zF a `s   4AE!