The second way is more risky if your hardware have malware such as keylogger, so the first way is better.
Both ways, first and second are risky if his/her device has malware like keyloggers that's why having strong and updated anti-virus is a huge help.