Here are 2 ways that come to mind
convert each character to its ASCII value
$ echo John | perl -lne 'printf "%03d", ord for split ""'
074111104110
Or, if you don't strictly need _numbers_ , just a code, base64
$ echo John | base64
Sm9obgo=
* * *
To decode:
$ echo 074111104110 | perl -ne 'print chr for /(\d{3})/g'
John
$ echo Sm9obgo= | base64 --decode
John