mogest / unix-crypt

Performs the UNIX crypt(3) algorithm in Ruby using DES, MD5, SHA256 or SHA512
BSD 3-Clause "New" or "Revised" License
61 stars 6 forks source link

Allow umlauts in passwords #4

Closed pencil closed 11 years ago

pencil commented 11 years ago

Fixes the following error:

Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8

pencil commented 11 years ago

Added. And moved it to the valid? method to fix the error for SHA as well.

mogest commented 11 years ago

Thanks. I'll merge this, but I'm going to make a change to how it's done:

if password.respond_to?(:encode)
  password = password.encode("UTF-8")
  password.force_encoding("ASCII-8BIT")
end

so that non-UTF8 strings get converted to UTF-8 first. force_encoding updates the string itself, too, so having that copy there means the caller doesn't get their string changed on them.

Thanks again!

pencil commented 11 years ago

Thank you :+1: