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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:21:53+00:00 2026-06-10T02:21:53+00:00

I’m having trouble unencoding some data I get from a socket connection through messagepack,

  • 0

I’m having trouble unencoding some data I get from a socket connection through messagepack, and consequentially unencrypting it. I get the string in from a Ruby on Rails web application in UTF-8 and use messagepack to bundle it all up and send it over to a python service using sockets. The other data comes across fine: strings, numbers, arrays etc. But my encrypted password is wrecked.

https://github.com/msgpack/msgpack/issues/15 this discussion suggested forcing ascii which i did in the rails code as well as here in python. If i force ascii in ruby and do nothing inpython i get junk in the string but i have the correct unencrypted password at the end. If i try to force ascii in my python script i get a decoding error

while 1:
    buf = clientsocket.recv(1024)
    unpacker.feed(buf)
    for obj in unpacker:
        print obj #works great! => ['3', [['really long url', [87987234, 'gobbledyguck of password']]]]
        #key.decrypt(obj[1][0][1][1]) roughly gives "YD3zt�(-�½ï¿½ï¿½=you suck"
        print key.decrypt(obj[1][0][1][1].decode('ascii'))

encryption is done using public/private keys (Crypto.PublicKey RSA in Python, openssl in ruby). i can decrypt and encrypt fine within each script (not sending it over the socket via messagepack)

any thoughts at all?

EDIT:
after some experimentation and a bit of thought, i realized that the fact that password comes out just fine is interesting. the issue is the extra junk at the beginning of the string. I just don’t know where it comes from… or whether its safe to truncate it.

  • 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-10T02:21:54+00:00Added an answer on June 10, 2026 at 2:21 am

    The solution ended up being in the fact that the output had the correct unencrypted data with fluff. A couple of quick Google’s resulted in me learning that ruby’s openssl implementation of RSA public key’s by default has PKCS#1 padding turned on… it was hard to find a good python module quickly so the quick and dirty solution was found here

    http://kfalck.net/2011/03/07/decoding-pkcs1-padding-in-python

    which worked like a charm!

    as an alternative (and probably cleaner) solution http://stuvel.eu/files/python-rsa-doc/usage.html looked good.

    Looking at the ruby apidock for a way to not use padding was not intuitive http://www.ruby-doc.org/stdlib-1.9.3/libdoc/openssl/rdoc/OpenSSL/PKey/RSA.html#method-i-public_encrypt

    hopefully this helps someone else

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
Specifically, suppose I start with the string string =hello \'i am \' me And

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.