Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6880549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:59:18+00:00 2026-05-27T04:59:18+00:00

i try to read file of bytes written in hex for example: (909090) which

  • 0

i try to read file of bytes written in hex for example: (909090) which is nop nop nop in assembly, i want to xor each two digit as a byte with the 0x91.

how do i print the value in hex? now it prints just numbers with no meaning.

in general i want to build a packer to my assembly code.

def add_prefix(a):
    a = str(a)
    a = '0x' + a
    a = int(a, 16)
    return a

fr = open('C:\code.txt', 'r')
word = ''
b = ''
for line in fr:
    b += line

count = 0

for char in b:
    char = str(char)
    word += char
    if count%2 == 0:
        word = int(str(add_prefix(word)^91), 16)
        print word
        word = ""
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:59:18+00:00Added an answer on May 27, 2026 at 4:59 am

    The algorithm needed is quite simple:

    1. read two characters at a time
    2. convert these to an integer
    3. Xor the integer with your mask (0x91)
    4. Convert the integer back to a hex string (with leading zero)

    with open(file_path, 'r') as fp:
        result = []
        while True:
            # 1.
            s = fp.read(2)
            if not s:
                break
    
            # 2. 
            number = int(s, 16) # No need for '0x' prefix!
    
            # 3.
            number = number ^ 0x91  # '91' needs '0x' prefix!
    
            # 4.
            result.append(format(number, '02x'))
    
    print ''.join(result)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a file (test.txt) which contains 1234567. However when I try to read
I'm trying to read a binary file which is a series of bytes and
I try to read file /proc/'pid'/status, using c program. The code is as follows,
Did anyone try to read programmatically an Alibre Design CAD file? I see that
fopen is failing when I try to read in a very moderately sized file
I have a very big file 4GB and when I try to read it
I have an app.config file inside my TestProject, but when I try to read
When I try to use curl or file_get_contents to read something like http://example.com/python/json/ from
I have to read a binary file in python. This is first written by
When I try to read bash history into vim, I get nothing. :r !history

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.