Fixes issue #478: Improved the generation of secret key