Is the key safe if attacker know the encrypted and decrypted message?
For any proper encryption algorithm, it is safe. The type of vulnerability you are describing is a key recovery attack or a forgery attack involving known plaintext-ciphertext pairs. Only very insecure ciphers are vulnerable to that attack, and strong, modern ones like AES are not.