I am not familiar with Unix or Linux,
but I know you can use system command by:
$encryedstring = exec("you command here");
or
$encryedstring = system("you command here");
to get your result if the "gnupg" can generate the code in one line.
also, you can use md5() or crypt() replace the gnupg to encryt the string.