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

  • Home
  • SEARCH
  • 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 7695149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:28:59+00:00 2026-05-31T21:28:59+00:00

I am a newbie in Python. I try to work with server using Thrift

  • 0

I am a newbie in Python. I try to work with server using Thrift protocol

struct AuthSalt {
    1: required i64 client,   /* random data */
    2: required i64 server,   /* data from previous answer */
}

struct AuthRequest {
    1: required AuthSalt bootstrap,
    2: required string who,           /* login */
    3: required string signature,     /* SHA-1: bootstrap + password + who + bootstrap. */
}

exception NotAuthorisedException {
    1: required string description
}

service Bookworm {
    AuthResponse Authenticate( 1: required AuthRequest a, 2: required string locale )
        throws ( 1: NotAuthorisedException e )
}

I need to create SHA1 digest using this algoritm: bootstrap + password + who + bootstrap.

To create bootstrap I use this:

dig = hashlib.sha1
bootstrap = AuthSalt(0, 0)
dig.update(bootstrap)
dig.update(password + who)
dig.update(bootstrap)

But update method argument type only string and I can’t understand how to convert bootstrap to a string.

In C++ this code looks like:

SHA_CTX c;
            ::SHA1_Init(&c);
            ::SHA1_Update(&c, &bootstrap, sizeof(bootstrap));
            ::SHA1_Update(&c, password.c_str(), password.size());
            ::SHA1_Update(&c, who.c_str(), who.size());
            ::SHA1_Update(&c, &bootstrap, sizeof(bootstrap));
            ::SHA1_Final(digest, &c);

Can someone explain how to do it using python?

Thanks in advance!

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

    This is what I was need:

    for x in tuple(struct.pack("Q",bootstrap.client)):
      dig.update(x)
    

    Convert i64 into 8 bytes and update hash with every byte

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

Sidebar

Related Questions

I'm a newbie to Python and I'm looking at using it to write some
I'm newbie in Python. I can't understand why this code does not work: reOptions
I'm a python newbie and starting out with using the Bottle web framework on
I'm a Python(3.1.2)/emacs(23.2) newbie teaching myself tkinter using the pythonware tutorial found here .
A python newbie question: I need to do the following try: do-something() except error1:
Newbie question. Pylons 1 + SQLA using declarative style. New to Python. I have
I am a newbie at Django and everytime I try to run python panel/manage.py
Python newbie here: I'm writing a market simulation in Python using Pysage, and want
I'm a newbie to python and the app engine. I have this code that
I am a newbie to Python and have come across the following example in

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.