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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:39:30+00:00 2026-06-15T19:39:30+00:00

I wrote 2 funcs that work good, but I want to change part of

  • 0

I wrote 2 funcs that work good, but I want to change part of my code to make it more efficient, using for loop with “jump” of every 8 charts.
when I run verify_checksum, I get:

AttributeError: 'int' object has no attribute 'split'

but when I run it with lines remarks with # it works fine.
any idea how fix it without change other parts of the code? (there are more funcs that works with these, and its cause a mess).

my code:

def xor_bytes(byte1, byte2):
    byte1, byte2=byte1.split(), byte2.split()
    xor=""
    a=0
    for i in byte1:
        for j in i:
            t=int(byte2[0][a])^int(j)
            xor+="".join(str(t))
            a+=1
    return xor


def verify_checksum(datagram):
    datagram=list(datagram)
    org_checksum=datagram[48:56]
    org_checksum="".join(org_checksum)
    x=48
    for i in datagram[48:56]:
        datagram[x]='0'
        x+=1
    datagram="".join(datagram)

    res=xor_bytes(datagram[0:8], datagram[8:16])
    for i in (16,88,8):
        res=xor_bytes(res, i)
    #res=xor_bytes(res,datagram[16:24])
    #res=xor_bytes(res,datagram[24:32])
    #res=xor_bytes(res,datagram[32:40])
    #res=xor_bytes(res,datagram[40:48])
    #res=xor_bytes(res,datagram[48:56])
    #res=xor_bytes(res,datagram[56:64])
    #res=xor_bytes(res,datagram[64:72])
    #res=xor_bytes(res,datagram[72:80])
    #res=xor_bytes(res,datagram[80:88])

    if res==org_checksum:
        return True
    else:
        return False 

input:

verify_checksum("1111000000001111000011111111000001010101101010101010111001110011001000000110101101101001")

output:

True
  • 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-15T19:39:32+00:00Added an answer on June 15, 2026 at 7:39 pm

    In the lines that are commented out, you’re passing two strings as parameters.

    In the loop, you’re passing a string and an int as parameters.

    The error is on the byte2.split() since it’s an int. Pass in a section of the datagram, not a numeric position and you’ll be fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a process explorer using C with GUI interface. I want to add
I'm trying to put some C hooks into some code that someone else wrote
I wrote a test dll in C++ to make sure things work before I
I want to write a drupal module that serves static files, but I want
I wrote a simple XML file and a DTD file including an entity, but
I wrote a PHP script that retrieves values from a MySQL Query. I used
I want to write a macro to write a string, using the compile-time optimisation
I wrote an alarm app with some complex code i dont feel like breaking
I want to write a function that calls another function with its arguments. See
I have a class that reads a pop3 email server. I want to write

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.