0

I want to get the same Value (PasswordHash) in Python like when I got it in bytes in C#

C# code:

byte [] bytes = Convert.FromBase64String("AQAAAAEAACcQAAAAEAco3n3jFZc+9/IXf5IFpCnLz7Yx/c8lAw+cZ3JvFcWA8xL1Oa90gX/yzB6h6KsUgg==");
Text = BitConverter.ToString(bytes).Replace("-", string.Empty);
//output is 010000000100002710000000100728DE7DE315973EF7F2177F9205A429CBCFB631FDCF25030F9C67726F15C580F312F539AF74817FF2CC1EA1E8AB1482

Python code:

x="AQAAAAEAACcQAAAAEAco3n3jFZc+9/IXf5IFpCnLz7Yx/c8lAw+cZ3JvFcWA8xL1Oa90gX/yzB6h6KsUgg=="
x_bytes = base64.b64decode(x)
y=str(x_bytes)[2:]
print(y.replace('\\x',''))
#output is 01000000010000'100000001007(de}e31597>f7f2177f9205a4)cbcfb61fdcf%030f9cgro15c580f312f59aft817ff2cc1ea1e8ab1482"

Can you please explain the difference?

1 Answer 1

1

They both produce the same sequence of bytes:

01 00 00 00 01 00 00 27 10 00 00 00 10 07 28 DE
7D E3 15 97 3E F7 F2 17 7F 92 05 A4 29 CB CF B6
31 FD CF 25 03 0F 9C 67 72 6F 15 C5 80 F3 12 F5
39 AF 74 81 7F F2 CC 1E A1 E8 AB 14 82

You just treat them differently after decoding them.

Looks like you want the hex of the bytes. All you need is

bytes.hex()
>>> import base64
>>> b64 = "AQAAAAEAACcQAAAAEAco3n3jFZc+9/IXf5IFpCnLz7Yx/c8lAw+cZ3JvFcWA8xL1Oa90gX/yzB6h6KsUgg=="
>>> bytes = base64.b64decode(b64)
>>> bytes.hex()
'010000000100002710000000100728de7de315973ef7f2177f9205a429cbcfb631fdcf25030f9c67726f15c580f312f539af74817ff2cc1ea1e8ab1482'
Sign up to request clarification or add additional context in comments.

2 Comments

I need to have python Output same like C# but i don't know how
Added. . . . . . .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.