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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:00:55+00:00 2026-05-17T21:00:55+00:00

In python, how does one split a SHA256 hash into a 32bit prefixes? I’m

  • 0

In python, how does one split a SHA256 hash into a 32bit prefixes? I’m working with Google’s safebrowsing api, which requires that I compare 32bit prefixes between my own collection, and the collection the API sends to me. I understand how to pull the list from Google, and I understand how to form a collection of hashes from parsed URLs, however, I don’t understand how I am to derive the first 32bits of each hash.

And after obtaining the prefix, would the best course of action between to place them in a dictionary with corresponding key/value pairs being the prefix/full hash, so that I can reference them later?

  • 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-17T21:00:55+00:00Added an answer on May 17, 2026 at 9:00 pm

    32 bits is the first 4 bytes. So you can slice the byte array.

    hash_obj.digest()[:4]
    

    You can take that and use it as a dictionary key.

    EDIT

    I’m not sure if you need the hex representation, that would be.

    hash_obj.hexdigest()[:8]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a Python function to split text into words, ignoring specified punctuation. Here
How does one create a Python friendly environment in Xcode 4, 5, 6 or
How does one work with string resources in python/gae in eclipse+pydev environment? looking for
I'm looking to increment a value by one and Python does not have the
Does Python have a unit testing framework compatible with the standard xUnit style of
Does python have the ability to create dynamic keywords? For example: qset.filter(min_price__usd__range=(min_price, max_price)) I
How does Python evaluate the expression 1+++2 ? How many ever + I put
Does Python have extension methods like C#? Is it possible to call a method
How does Python's slice notation work? That is: when I write code like a[x:y:z]
Does * have a special meaning in Python as it does in C? I

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.