Method for authentication and device thereof