Question: I've got myself a bit confused regarding variables in Python, just looking for a bit of clarification. 

In the following code, I will pass a global variable into my own Python function which simply takes the value and multiplies it by 2. Very simple. It does not return the variable after. The output from the print function at the end prints 10500 rather than 21000, indicating that the local variable created within the function did not actually edit the global variable that was passed to, but rather used the value as its argument. 

```
balance = 10500

def test(balance):
    balance = balance * 2

test(balance)
print(balance)

```

However, in my second piece of code here, when I pass a list/array into a separate function for bubble sorting, it is the actual array that is edited, rather than the function just using the values. 

```
def bubble_sort(scores):
    swapped = True
    while swapped:
        swapped = False
        for i in range(0, len(scores)-1):
            if scores[i] > scores[i+1]:
                temp = scores[i]
                scores[i] = scores[i+1]
                scores[i+1] = temp
                swapped = True

scores = [60, 50, 60, 58, 54, 54]

bubble_sort(scores)
print(scores)

```

Now when I print my scores list, it has been sorted. I am confused as to why the top function did not change the global variable that was passed to it, while the second function did? I understand using the global keyword within functions means I am still able to write code that will edit a global variable within my own functions, but maybe I am missing some basic understanding.

Answer: 
Thank You Botje! Thank You very much for trying to help me.
But I have no time anymore for learning openssl. So I found a great one:
**<https://github.com/Thalhammer/jwt-cpp>**
from here
**jwt.io**

It doesn't support the 'scope' field for the jwt-claim, so I just added a method into a class into a header: 'set\_scope(...);'.

Ten, 10... Nooo, You just can't feel my pain beacuse of openssl\_from\_devs\_with\_crooked\_hands\_with\_no\_human\_docs.
10 strings of a code and it's done! 

It has simple sources, so You can find out how to work with ssl from there.
If You want to use OpenSSL lib and don't know how it works - **think twice**, may be it's the worst choice of Your life. Good luck!
No need to mark this answer as accepted, yours is by far the easier solution. I'm posting this for future readers to find.

For what it's worth, I was able to reproduce the raw hash in the RS256 test case with the following:

```
void die() {
    for (int err = ERR_get_error(); err != 0; err = ERR_get_error()) {
        fprintf(stderr, "%s\n", ERR_error_string(err, nullptr));
    }
    exit(1);
}

int main() {
    /* md is a SHA-256 digest in this example. */
    BIO *pem_BIO = BIO_new_mem_buf(RSA_pem, sizeof(RSA_pem));
    EVP_PKEY *signing_key = PEM_read_bio_PrivateKey(pem_BIO, nullptr, nullptr, nullptr);

    const unsigned char header_payload[] = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXUyJ9.eyJpc3MiOiJhdXRoMCJ9";

    EVP_MD_CTX * MD_ctx = EVP_MD_CTX_new();
    bool success = true;
    success = EVP_DigestSignInit(MD_ctx, nullptr, EVP_get_digestbyname(SN_sha256WithRSAEncryption), nullptr, signing_key);
    if (!success) die();

    unsigned char sigbuf[512];
    size_t siglen = sizeof(sigbuf);
    success = EVP_DigestSign(MD_ctx, sigbuf, &siglen, header_payload, sizeof(header_payload)-1);
    if (!success) die();
    fwrite(sigbuf, 1, siglen, stdout);
}

```

The end result still has to be base64-encoded (with the url-safe alphabet), though.