Let's talk code

My PGP key fingerprint is 704F C50C E572 DE89 DF9F 4323 6898 544F 1DC2 3CBE.

curl https://arindrarto.dev/0x1DC23CBE.pub.asc | gpg --import

I am also reachable at T3R673XU4HR7JQHB6LU65ZEB6KG6D4U36SD67LU74SLJHZPW . Use one of the decoders below and let me know which implementation you select. Alternatively, roll your own and let's talk about it, too ☺.

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);
}