Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

246
Views
javascript btoa error 'The String contains an invalid characters'

A login screen for user email and password is generating an error that I have not been able to reproduce. I have looked extensively for a solution, and everything I see is referencing atob or urlEncoding issues. Virtually nothing about btoa.

  <input type="password" id="loginPassword" placeholder="password" class="registerFields"  ng-model="loginInfo.password"></input>


  $scope.userLogin = function() {
    // check user on back end
    var pass64 = btoa($scope.loginInfo.password) ;  // <-- error generated here
    ....
  } ;

I am encoding the string to pass back to my server, which decodes the string using PHP then properly compares the password to what is stored in the DB.

  $user_password = base64_decode($inObj['upass']) ;

  if (password_verify($user_password,$rows[0]['user_password'])) {
     ...
  }

Everything I have been reading is the error that is being reported would be caused by users entering Unicode characters into the password field. Is this the only case that could cause this error or are there others? Trying to replicate the error I have entered about a dozen unicode strings, even the enter key (U+2386) but every example I am testing with does not produce an error.

  1. What characters or strings could be causing this so that I can try to replicate it?
  2. What can I do to prevent the error OR, if possible, prevent unicode characters from being entered as a password (is that even a good idea) ?
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!