I don't think it makes much sense to introduce a function as the code blocks differ to some extend. e.g. the `STDIN` block uses a bash-variable to store a base64 encoded representation of the bytes read via stdin, while  the file-based block uses pass the filename to `wc` and `base64`. also does the stdin block could not provide a filename.

how or which part do you suggest to wrap in a function?