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 9121073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:46:38+00:00 2026-06-17T05:46:38+00:00

I have written a simple python module that reads in a file and converts

  • 0

I have written a simple python module that reads in a file and converts the read data to a list of hex values. I then incremented each value by 1. I was wondering how I could write this list of hex values to a new file.

Using python 3.x

Code:

inFilePath = input("Input File: ")
inFile = open(inFilePath, "rb")
data = inFile.read()
hexVals = []
for byte in data:
    hexVals.append(hex(byte))
print("File Read")
print("Original Data: " + str(hexVals))
for x in range(hexVals.__len__()):
    hexVals[x] = hex(int(hexVals[x], 16) + 1)
print("Altered Data: " + str(hexVals))
outFilePath = input("Output File: ")
outFile = open(outFilePath, "wb")
outFile.write(???)
  • 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-06-17T05:46:39+00:00Added an answer on June 17, 2026 at 5:46 am

    You’re storing your bytes as hexadecimal strings. You can do that, but it already gives the result to you as integers. Just leave it as integers, although you may want to convert it into a list. After it’s been converted to a list, you can convert it back into bytes in a rather simple way. For example:

    with open('input', 'rb') as f:
        data = f.read()
    data = list(data)
    data = [byte + 1 for byte in data]
    data = bytes(data)
    # If this is all you're going to do, you could just do this:
    # data = bytes((byte + 1) % 256 for byte in data)
    with open('output', 'wb') as f:
        f.write(data)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well, i have written a simple python program that parses HTML with HTMLParser. Here
I have a simple script written in both Python and Haskell. It reads a
I have written simple code to get content from xml file to php. $xml
I have written a simple WCF service that accepts and stores messages. It works
I have written a simple CRUD form which has one select list. However the
I have written a simple python program l=[1,2,3,0,0,1] for i in range(0,len(l)): if l[i]==0:
I have written a simple python script to check if squid works normally /scripts/proxychecker
Basically I have written two modules for my Python Program. I need one module
I am new to Python and I have written this simple script: #!/usr/bin/python3 import
I've written a very simple python numpy code. It have a strange behavior... from

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.