In light of the discovered weakness in the Type 4 password encryption mechanism, this is a way of generating Type 5 passwords using OpenSSL:
openssl passwd -salt `openssl rand -base64 3` -1 PLAINTEXT_PASSWORD
After which it can be copied to the target device:
username USER secret 5 RESULTING_HASH
Source: Cisco Security Response – Cisco IOS and Cisco IOS XE Type 4 Passwords Issue