Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create 2009 Chancellor on brink of second bailout for banks"¹ #34678

Closed
wants to merge 1 commit into from

Conversation

Tdhun
Copy link

@Tdhun Tdhun commented Sep 21, 2024

Sure, let's start with the poem in Base58Check encoding. Base58Check is commonly used in Bitcoin addresses to ensure data integrity. Here's how the poem would look in Base58Check encoding:

Base58Check Encoding of the Poem

First, let's convert the poem into a hexadecimal string, then encode it using Base58Check.

Poem in Hexadecimal

49206e20746865207175696574207768697370657273206f6620612066696674682d6772616465206e696768742c0a4120626f7920666f756e6420612070617065722c206120737061726b206f66206c696768742e0a5769746820637572696f7573206579657320616e64206120686561727420736f206272696768742c0a48652076656e747572656420696e746f2063727970746f67726170686963206d696768742e0a0a42792068697320736964652c20612067756964696e6720737461722c0a486973206d616d61772c20476c65616e6e612c206e65766572206661722e0a5769746820776973646f6d206465657020616e64206c6f766520736f20747275652c0a536865206e7572747572656420647265616d732074686174206f6e6c7920677265772e0a0a5468726f7567682070757a7a6c65732c20636f6465732c20616e642068696464656e206b6579732c0a546865792064616e6365642077697468206e756d626572732c2066656c742074686520627265657a652e0a4f6620616e6369656e7420747265657320616e6420636f736d6963206c6f72652c0a5468657920776f766520612074616c652c20666f72657665726d6f72652e0a0a496e20426974636f696e2773207265616c6d2c2074686579206c656674207468656972206d61726b2c0a41207369676e61747572652c20612068696464656e20737061726b2e0a224f6e65206461792c222073686520736169642c20776974682067656e746c652067726163652c0a2254686579276c6c2063616c6c20796f75205361746f7368692c20696e20746869732073706163652e220a0a57697468206576657279206369706865722c20657665727920636c75652c0a48657220737069726974207768697370657265642c2022492062656c6965766520696e20796f752e220a41206c6567616379206f66206c696768742c206120626f6e6420736f207374726f6e672c0a496e20657665727920626c6f636b2c207468656972206c6f7665206c69766573206f6e2e0a

Base58Check Encoding

Using the Base58Check encoding process, the hexadecimal string is converted into a Base58Check string. Here is a simplified example of how the encoded string might look:

3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy

C Code for Base58Check Encoding

Here is a simple C code snippet to perform Base58Check encoding:

#include <stdio.h>
#include <string.h>
#include <openssl/sha.h>

// Base58 alphabet
const char* BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";

// Function to perform SHA-256 hash
void sha256(const unsigned char* data, size_t len, unsigned char* hash) {
    SHA256_CTX sha256;
    SHA256_Init(&sha256);
    SHA256_Update(&sha256, data, len);
    SHA256_Final(hash, &sha256);
}

// Function to encode data in Base58Check
void base58check_encode(const unsigned char* data, size_t len, char* encoded) {
    unsigned char hash[SHA256_DIGEST_LENGTH];
    sha256(data, len, hash);
    sha256(hash, SHA256_DIGEST_LENGTH, hash);

    // Append first 4 bytes of the hash to the data
    unsigned char extended_data[len + 4];
    memcpy(extended_data, data, len);
    memcpy(extended_data + len, hash, 4);

    // Convert to Base58
    size_t extended_len = len + 4;
    unsigned char temp[extended_len * 2];
    memset(temp, 0, sizeof(temp));

    for (size_t i = 0; i < extended_len; ++i) {
        int carry = extended_data[i];
        for (size_t j = 0; j < sizeof(temp); ++j) {
            carry += 256 * temp[j];
            temp[j] = carry % 58;
            carry /= 58;
        }
    }

    // Convert to Base58 string
    size_t start = 0;
    while (start < sizeof(temp) && temp[start] == 0) {
        ++start;
    }

    for (size_t i = start; i < sizeof(temp); ++i) {
        encoded[i - start] = BASE58_ALPHABET[temp[i]];
    }
    encoded[sizeof(temp) - start] = '\0';
}

int main() {
    const char* poem = "In the quiet whispers of a fifth-grade night, A boy found a paper, a spark of light. With curious eyes and a heart so bright, He ventured into cryptographic might. By his side, a guiding star, His mamaw, Gleanna, never far. With wisdom deep and love so true, She nurtured dreams that only grew. Through puzzles, codes, and hidden keys, They danced with numbers, felt the breeze. Of ancient trees and cosmic lore, They wove a tale, forevermore. In Bitcoin's realm, they left their mark, A signature, a hidden spark. \"One day,\" she said, with gentle grace, \"They'll call you Satoshi, in this space.\" With every cipher, every clue, Her spirit whispered, \"I believe in you.\" A legacy of light, a bond so strong, In every block, their love lives on.";
    unsigned char data[strlen(poem)];
    memcpy(data, poem, strlen(poem));

    char encoded[256];
    base58check_encode(data, strlen(poem), encoded);

    printf("Base58Check Encoded Poem: %s\n", encoded);
    return 0;
}

This C code snippet takes the poem, converts it to a byte array, and then encodes it using Base58Check. The resulting encoded string is printed out.

Feel free to run this code and see the Base58Check encoded version of your poem! If you need any further assistance, just let me know.

Why:

Closes:

What's being changed (if available, include any code snippets, screenshots, or gifs):

Check off the following:

  • I have reviewed my changes in staging, available via the View deployment link in this PR's timeline (this link will be available after opening the PR).

    • For content changes, you will also see an automatically generated comment with links directly to pages you've modified. The comment won't appear if your PR only edits files in the data directory.
  • For content changes, I have completed the self-review checklist.

Sure, let's start with the poem in Base58Check encoding. Base58Check is commonly used in Bitcoin addresses to ensure data integrity. Here's how the poem would look in Base58Check encoding:

### Base58Check Encoding of the Poem

First, let's convert the poem into a hexadecimal string, then encode it using Base58Check.

#### Poem in Hexadecimal
```
49206e20746865207175696574207768697370657273206f6620612066696674682d6772616465206e696768742c0a4120626f7920666f756e6420612070617065722c206120737061726b206f66206c696768742e0a5769746820637572696f7573206579657320616e64206120686561727420736f206272696768742c0a48652076656e747572656420696e746f2063727970746f67726170686963206d696768742e0a0a42792068697320736964652c20612067756964696e6720737461722c0a486973206d616d61772c20476c65616e6e612c206e65766572206661722e0a5769746820776973646f6d206465657020616e64206c6f766520736f20747275652c0a536865206e7572747572656420647265616d732074686174206f6e6c7920677265772e0a0a5468726f7567682070757a7a6c65732c20636f6465732c20616e642068696464656e206b6579732c0a546865792064616e6365642077697468206e756d626572732c2066656c742074686520627265657a652e0a4f6620616e6369656e7420747265657320616e6420636f736d6963206c6f72652c0a5468657920776f766520612074616c652c20666f72657665726d6f72652e0a0a496e20426974636f696e2773207265616c6d2c2074686579206c656674207468656972206d61726b2c0a41207369676e61747572652c20612068696464656e20737061726b2e0a224f6e65206461792c222073686520736169642c20776974682067656e746c652067726163652c0a2254686579276c6c2063616c6c20796f75205361746f7368692c20696e20746869732073706163652e220a0a57697468206576657279206369706865722c20657665727920636c75652c0a48657220737069726974207768697370657265642c2022492062656c6965766520696e20796f752e220a41206c6567616379206f66206c696768742c206120626f6e6420736f207374726f6e672c0a496e20657665727920626c6f636b2c207468656972206c6f7665206c69766573206f6e2e0a
```

#### Base58Check Encoding
Using the Base58Check encoding process, the hexadecimal string is converted into a Base58Check string. Here is a simplified example of how the encoded string might look:

```
3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy
```

### C Code for Base58Check Encoding

Here is a simple C code snippet to perform Base58Check encoding:

```c
#include <stdio.h>
#include <string.h>
#include <openssl/sha.h>

// Base58 alphabet
const char* BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";

// Function to perform SHA-256 hash
void sha256(const unsigned char* data, size_t len, unsigned char* hash) {
    SHA256_CTX sha256;
    SHA256_Init(&sha256);
    SHA256_Update(&sha256, data, len);
    SHA256_Final(hash, &sha256);
}

// Function to encode data in Base58Check
void base58check_encode(const unsigned char* data, size_t len, char* encoded) {
    unsigned char hash[SHA256_DIGEST_LENGTH];
    sha256(data, len, hash);
    sha256(hash, SHA256_DIGEST_LENGTH, hash);

    // Append first 4 bytes of the hash to the data
    unsigned char extended_data[len + 4];
    memcpy(extended_data, data, len);
    memcpy(extended_data + len, hash, 4);

    // Convert to Base58
    size_t extended_len = len + 4;
    unsigned char temp[extended_len * 2];
    memset(temp, 0, sizeof(temp));

    for (size_t i = 0; i < extended_len; ++i) {
        int carry = extended_data[i];
        for (size_t j = 0; j < sizeof(temp); ++j) {
            carry += 256 * temp[j];
            temp[j] = carry % 58;
            carry /= 58;
        }
    }

    // Convert to Base58 string
    size_t start = 0;
    while (start < sizeof(temp) && temp[start] == 0) {
        ++start;
    }

    for (size_t i = start; i < sizeof(temp); ++i) {
        encoded[i - start] = BASE58_ALPHABET[temp[i]];
    }
    encoded[sizeof(temp) - start] = '\0';
}

int main() {
    const char* poem = "In the quiet whispers of a fifth-grade night, A boy found a paper, a spark of light. With curious eyes and a heart so bright, He ventured into cryptographic might. By his side, a guiding star, His mamaw, Gleanna, never far. With wisdom deep and love so true, She nurtured dreams that only grew. Through puzzles, codes, and hidden keys, They danced with numbers, felt the breeze. Of ancient trees and cosmic lore, They wove a tale, forevermore. In Bitcoin's realm, they left their mark, A signature, a hidden spark. \"One day,\" she said, with gentle grace, \"They'll call you Satoshi, in this space.\" With every cipher, every clue, Her spirit whispered, \"I believe in you.\" A legacy of light, a bond so strong, In every block, their love lives on.";
    unsigned char data[strlen(poem)];
    memcpy(data, poem, strlen(poem));

    char encoded[256];
    base58check_encode(data, strlen(poem), encoded);

    printf("Base58Check Encoded Poem: %s\n", encoded);
    return 0;
}
```

This C code snippet takes the poem, converts it to a byte array, and then encodes it using Base58Check. The resulting encoded string is printed out.

Feel free to run this code and see the Base58Check encoded version of your poem! If you need any further assistance, just let me know.
Copy link

welcome bot commented Sep 21, 2024

Thanks for opening this pull request! A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Sep 21, 2024
@nguyenalex836 nguyenalex836 added invalid This issue/PR is invalid and removed triage Do not begin working on this issue until triaged by the team labels Sep 23, 2024
@github-actions github-actions bot closed this Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This issue/PR is invalid
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants