Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
encode / encode-base64-decodeOpenRuns on Liberas

Base64 decode

Decodes base64 (RFC 4648 §4) strictly. The alphabet is A–Z a–z 0–9 + /; the length must be a multiple of 4; "=" may appear only as the last one or two characters (the final group is xxxx, xxx= or xx==); the unused low bits of the last character before the padding must be zero ("Zg==" → "f", "Zh==" is an error). Any other character, including whitespace, line breaks, "-", "_" and non-ASCII, is an error, as is every input not of this form. The empty string decodes to no bytes. text is a string of at most 16 MiB (16,777,216 bytes of UTF-8); more is an error. The result is bytes (base64 in JSON).

From your terminal

terminal
npm i -g https://liberas.dev/cli/liberas.tgz
export LIBERAS_URL=https://liberas.dev
liberas init encode-base64-decode --lang rust
cd encode-base64-decode && liberas build && liberas submit

Save a token once with liberas login (make it on your page, /me, after signing in). init scaffolds the interface, the vectors and a stub in Rust (--lang js for light specs).

Interface (WIT)11 lines›
encode-base64-decode.wit
package root:component;

world root {
  export liberas:encode/decoder@0.1.0;
}
package liberas:encode@0.1.0 {
  interface decoder {
    decode: func(text: string) -> result<list<u8>, string>;
  }
}
Test vectors22›
encode-base64-decode.cases.json
[
  {
    "args": {
      "text": ""
    }
  },
  {
    "args": {
      "text": "Zg=="
    }
  },
  {
    "args": {
      "text": "Zm8="
    }
  },
  {
    "args": {
      "text": "Zm9v"
    }
  },
  {
    "args": {
      "text": "Zm9vYg=="
    }
  },
  {
    "args": {
      "text": "Zm9vYmE="
    }
  },
  {
    "args": {
      "text": "Zm9vYmFy"
    }
  },
  {
    "args": {
      "text": "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="
    }
  },
  {
    "args": {
      "text": "+/+/"
    }
  },
  {
    "args": {
      "text": "AAAA"
    }
  },
  {
    "args": {
      "text": "Zg="
    }
  },
  {
    "args": {
      "text": "Zh=="
    }
  },
  {
    "args": {
      "text": "Zm9="
    }
  },
  {
    "args": {
      "text": "Zg==Zg=="
    }
  },
  {
    "args": {
      "text": "Zm9v\n"
    }
  },
  {
    "args": {
      "text": " Zm9v"
    }
  },
  {
    "args": {
      "text": "Zm9v-_8A"
    }
  },
  {
    "args": {
      "text": "===="
    }
  },
  {
    "args": {
      "text": "Z==="
    }
  },
  {
    "args": {
      "text": "Zg=a"
    }
  },
  {
    "args": {
      "text": "Zm9vYmFy="
    }
  },
  {
    "args": {
      "text": "한글AA"
    }
  }
]
Verification6›
  • Outputs must match the private reference implementation bit for bit.
  • Cases are the spec's 22 vectors plus ones generated from the interface's types: edge values and random ones seeded by your component's hash.
  • Components may import nothing but specs: no files, no network, no clock.
  • Runs on Liberas: the component never leaves the platform, and every call is metered on the ledger.
  • A remote call may execute up to 3,300,000,000 instructions.
  • Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.