2 Hours i have spent on this.
String key = base64encode(password);
What's solved me the issue was this "key.replaceAll("\r\n?", "");"
Hoping that it will assist you too and save you the time i already spent,
(The base64encode method based on apache-commons base64encoder)