[#2222] Refactor buffer_crypt::generate_key to be a static method