Fix secret key encode and add secret key hash