When you copy-paste examples from CryptoJS website then you copiend invisible characters also(zero width whitespace) They generate parsing errors which you mentioned: SyntaxError: Invalid or unexpected token. To solve this just type code manually. Or search for editor when you can view all non-printable characters and remove them.