~mjorgensen/jrgnsn.net

886c0564462bf12f631456c5c52e0582df3e76c2 — Matthew Jorgensen 9 months ago bde214b
Retroactively adding syntax highlighting to older posts
M _posts/2018-05-16-Base64-Encoding-in-Python-3.md => _posts/2018-05-16-Base64-Encoding-in-Python-3.md +13 -5
@@ 21,11 21,15 @@ the Account ID and Key to be base64 encoded in the following format:

Try this in a Python 2 shell:

    base64.b64encode('A string')
```python
base64.b64encode('A string')
```
    
You get an output like:

    'QSBzdHJpbmc='
```
'QSBzdHJpbmc='
```
    
Try running the same thing in a Python 3 shell and you see something
closer to this:


@@ 41,12 45,16 @@ string in `UTF-8`. Then, once it's base64 encoded, you decode that as

This works:

    base64.b64encode('A string'.encode('UTF-8')).decode('ascii')
```python
base64.b64encode('A string'.encode('UTF-8')).decode('ascii')
```

After doing some more scouring, I found [this Stackoverflow thread][1].

    # The following works, too, and looks a little neater.
    base64.b64encode(bytes('A string', 'utf-8')).decode('ascii')
```python
# The following works, too, and looks a little neater.
base64.b64encode(bytes('A string', 'utf-8')).decode('ascii')
```

Here's [another Stackoverflow thread][2] explaining why.


M _posts/2019-10-25-Prevent-Access-to-Shut-Down-Commands-Except-on-my-VMs.md => _posts/2019-10-25-Prevent-Access-to-Shut-Down-Commands-Except-on-my-VMs.md +1 -1
@@ 34,7 34,7 @@ this WMI Filer *Non-client OSes*. I renamed it after I added the query
to check if the machine in question is one of my VMs. Since my VMs have
a standard naming convention, my **two** WMI queries looked like this:

```
```sql
SELECT Name FROM Win32_OperatingSystem WHERE ProductType > 1
SELECT Name FROM Win32_ComputerSystem WHERE NOT Name LIKE 'MLJ-VM%'
```