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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:45:25+00:00 2026-05-20T22:45:25+00:00

I’m trying to hash a password to dump into a .rdp file. I found

  • 0

I’m trying to hash a password to dump into a .rdp file. I found a site that (more or less) shows how to do that here but it doesn’t work in 3.1.

In 2.5.4 I get this:

>>> import win32crypt
>>> import binascii
>>> pwdHash = win32crypt.CryptProtectData(u"password",u'psw',None,None,None,0)
>>> print str(binascii.hexlify(pwdHash)).upper()
01000000D08C9DDF0115D1118C7A00C04FC297EB010000007E9E... blah, blah blah

In 3.1 I get this (everything’s unicode in 3.1 so just ditch the u" right?):

>>> pwdHash = win32crypt.CryptProtectData("password",'psw',None,None,None,0)
Traceback (most recent call last):
  File "<pyshell#19>", line 1, in <module>
    pwdHash = win32crypt.CryptProtectData("password",'psw',None,None,None,0)
TypeError: expected an object with a buffer interface

OK, I’ve seen that error before and usually that just means I need to convert to bytes first, so:

>>> pwdHash = win32crypt.CryptProtectData("password".encode(),'psw',None,None,None,0)
>>> print(str(binascii.hexlify(pwdHash)).upper())
B'01000000D08C9DDF0115D1118C7A00C04FC297EB010000007E9E... blah, blah, blah
>>>

Which seems all well and good but that doesn’t work when you dump that hexed value into an .rdp file, I can only assume that’s because it isn’t a hex-crypt of the unicode string ‘password’ but a hex-crypt of the bytes ‘password’. I’ve attempted a .decode() but that does just what you’d expect and makes the hex-crypt bytes into a string, it doesn’t give you the hex-crypt string for the original unicode string.

I’ve googled like crazy for any info on the win32crypt.CryptProtectData and I can’t find any useful information on why it now requires a bytes or buffer object instead of a string.

Can anybody help?
(or does anyone know of an easier way to feed a password into a Remote Desktop session I’m opening programatically through Python? hehe)

  • 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-20T22:45:25+00:00Added an answer on May 20, 2026 at 10:45 pm

    Use “password”.encode(‘utf-16-le’) instead.

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

Sidebar

Related Questions

No related questions found

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.