Let's talk code

You can reach me at RX3ZBD6A4HZIZ2PO4SMPFFPB6L2O7DFO4SOOL5UW Hint: the first character is neither 'b' nor 'c' and this is not listed in the PGP key. using one of the decoders below. Let me know which implementation you choose. Or, roll your own and let's talk about it, too ☺.

I also have a PGP key: 07EF EC69 6E46 0E86 A036 8C94 D4EF 801C 7A10 C00C.

decode.py

#!/usr/bin/env python3.8

import sys
import binascii
from base64 import b32decode as b32d
from contextlib import suppress


def decode(value: str) -> str:
    ds = [b - 128 for b in b32d(value.encode())]
    return "".join(chr(d) for d in ds if d >= 32)


if __name__ == "__main__":
  with suppress(IndexError):
      try:
          decoded = decode(sys.argv[1])
          print(decoded)
      except binascii.Error:
          print("Error: invalid input", file=sys.stderr)
          sys.exit(1)

decode/src/main.rs

use std::process;
use data_encoding::{BASE32, DecodeError};  // version 2.2.0

fn decode(value: impl AsRef<[u8]>) -> Result<String, DecodeError> {
    let func = |x: &u8|
        if *x >= 160 { Some((x - 128) as char) }
        else { None };

    let vref = value.as_ref();
    let mut rv = String::with_capacity(vref.len() / 2);
    rv.extend(
        BASE32.decode(vref)?.iter().filter_map(func)
    );

    Ok(rv)
}

fn main() {
    if let Some(value) = std::env::args().skip(1).next() {
        let decoded = decode(value).unwrap_or_else(|_| {
            eprintln!("Error: invalid input value");
            process::exit(1);
        });
        println!("{}", decoded);
    }
}

decode.go

package main

import (
    "encoding/base32"
    "fmt"
    "os"
)

func decode(value string) (string, error) {
    ns, err := base32.StdEncoding.DecodeString(value)
    if err != nil {
        return "", err
    }

    cs := make([]rune, len(ns))
    for i, n := range ns {
        if n >= 160 {
            cs[i] = rune(n - 128)
        }
    }

    return string(cs), nil
}

func main() {
    if len(os.Args) > 1 {
        decoded, err := decode(os.Args[1])
        if err != nil {
            fmt.Fprintf(os.Stderr, "Error: invalid input value\n")
            os.Exit(1)
        }
        fmt.Println(decoded)
    }
}

decode.js

#!/usr/bin/env node

const process = require('process');
const base32 = require('hi-base32');  // version 0.5.0

const func = (acc, n) => (
  n >= 160
  ? `${acc}${String.fromCharCode(n - 128)}`
  : acc
);

const decode = (value) => base32
  .decode.asBytes(value)
  .reduce(func, '');

try {
  process.argv[2] && console.log(decode(process.argv[2]));
} catch {
  console.error("Error: invalid input");
  process.exit(1);
}