-3

I have some c# code. Could you, please, clarify how can do the same encoding result Python:

byte[] result = Convert.FromBase64String(Convert.ToBase64String(Encoding.Unicode.GetBytes("some_string")));
stuartd
  • 70,509
  • 14
  • 132
  • 163
  • 2
    What are you trying to do? To be specific, why do you base64-encode and then base64-decode again? – the default. Apr 26 '19 at 11:17
  • 2
    Your code doesn't really make sense. Why are you converting a string to an array of bytes, only to then encode to and directly afterwrds decode from Base64, only to contain the bytes? Wouldn't `var result = Encoding.Unicode.GetBytes("myString")` be better suited? – SimonC Apr 26 '19 at 11:18
  • @someone it is not my code - I just only need to get the same result – Evgeniya Apr 26 '19 at 11:21
  • https://stackoverflow.com/questions/11624190/python-convert-string-to-byte-array – xdtTransform Apr 26 '19 at 11:22
  • i will recommend reading the guidline [ask], and [mcve]. As Simply formulating a question will give you the answer. First you have to define what the C# code does: It take a `string` and return a `byte[]`. Then you make few test of this C# code storing input and output, it will become your test case. Step 3 you reformulate step 1 into a search engine: "python string to byte array". Step 4, you try solution you find and write an SO question specifying your input/output and the expected result. – xdtTransform Apr 26 '19 at 11:29
  • You can use step 4 only if the previous step failed. Beeing clear, and able to describe an issue could be one of the most valuable skill you can get in IT. – xdtTransform Apr 26 '19 at 11:33

1 Answers1

0

import base64 base64.b64encode(b'some_string')

13isbad
  • 1
  • 1