“Uncaught Error: InvalidCharacterError: DOM Exception 5” when AES256 encrypted and base64 encoded string is decoded on browser-Collection of common programming errors

At first, by ruby (I am using Rails), I made AES256 encrypted and base64 encoded string on server-side.

require 'aes'

# encrypt with AES256 and encode with base64
base64 = AES.encrypt("secret word", "pass")

Then, I want to decode this on browser with below libraries.

My JavaScript code is below.

base64encoded = $('span.base64:first').text();
encrypted = Base64.decode(base64encoded); //