generate key with method