Ignore the link in Gun’s post, its the first version and contains some bugs.
Here’s version 1.1
https://jsfiddle.net/NNuFP/2/embedded/result/
Fixes error on low personal ID’s.
Fixes bad placement of random ID on encoding and bad selection of random ID on decoding.