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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:51:00+00:00 2026-06-07T03:51:00+00:00

My server is coded in Python and I am making a java client for

  • 0

My server is coded in Python and I am making a java client for this server.

I am Signing a message(data) using:

public static byte[] Sign(PrivateKey privateKey, byte[] data) throws Exception{
        System.out.println("Signing the key inside RSACrypto#Sign");
        Signature dsa = Signature.getInstance("SHA1withRSA");

        SecureRandom secureRandom =null;
        dsa.initSign(privateKey,secureRandom);
        dsa.update(data);
        return dsa.sign();
}

This returns a byteArray(named signed_data) , now I am encoding this signature using Base64.encodeBase64 and converting the byteArray(named my_byte_array) so formed into string using :

String str = new String(my_byte_array)

and sending this string to Server.

On server side, I receive this string , then Server verifies the signature using:

publicKey.verify(str(data), (long(base64.b64decode(my_byte_array)),))

using library http://gdata-python-client.googlecode.com/hg/pydocs/gdata.Crypto.PublicKey.RSA.html

when I try to print my_byte_array on both side they are same, and so is signed_data and base64.b64decode(my_byte_array)

but I am getting this error:

ValueError: invalid literal for long() with base 10: '\x8b\xa1\xbb\x19fO\xea\xe7\xa4B\xd4\xd2\xa1\xe3\xb9\xd0\x89n\xa2\xfe\xb5\xedsL\x02\xba\xad\x12!qjp\x0c%+Z\t\xa7\x12\x08\x90\xfaTk\xca\xd0\xae\xd8\xa9\xfa\xbb]>9\x1c\x80\xd0

As far as I can think, this error is arising because Java signs the message into byte and python expects it to be in Long.

Is there a way to solve this problem?

  • 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-07T03:51:02+00:00Added an answer on June 7, 2026 at 3:51 am

    You have actually 2 problems.

    The first one is that – according to the Java Cryptograpy Architecture API – the SHA1withRSA algorithm involves PKCS#1 v1.5 padding. At the Python side, you must use the same padding scheme to verify the signature; that can be achieved with PyCrypto’s PKCS#1 v1.5 signature module (Crypto.Signature.PKCS1_v1_5).

    The second problem is the one you point out: the verify method of an RSA PyCrypto object
    oddly requires the signature to be encoded as an integer. However, by using the module I mentioned above, the problem will go away, since it accepts byte strings.

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

Sidebar

Related Questions

I have coded a server in Java that will have several clients connected to
Here is the server code package echoserver; import java.net.*; import java.io.*; public class EchoServer
I wrote a simple HTTP client and server in Python for experimenting. The first
I have a client written in Python for a server, which functions through LAN.
I have made a simple server -client code in python socket programming. Client side
How can I share a blob of data using a Twisted server, while at
I'm working on making a simple server application with python, and I'm trying to
Until recently, I posted Python code (whitespace matters) to blogspot.com using something like this:
I have some python code on both the client and server side. I am
I'm working on some Python code modeled on Apache's MPM prefork server. I am

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.