At work we have some dedicated time each week to learning new things or improve on old things, and earlier this week I had randomly read some stuff about Python. Since I have never gotten my hands dirty with Python I decided that it was time to change that.
I started out by following this guide to install Python in my VS Code environment and played a bit with the examples provided.
Then I decided to write a function to base64 encode username and password to be used for basic auth, just to see if I could:
import base64
EncodingAsString = "utf-8"
BasicPrefix = "Basic"
def GetBasicAuth(username, password):
encodedString = str(base64.b64encode(str(f"{username}:{password}").encode(EncodingAsString)), EncodingAsString)
return str(f"{BasicPrefix} {encodedString}")
print(GetBasicAuth("ebolakid", "blog"))
I guess it turned out alright for being written 15 minutes after a Python installation.
EDIT: Please note that the intendation didn’t quite fit the blog…
But copy-paste into your favorite editor should work just fine.