Skip to content

Commit

Permalink
fix hashing of prints with odd number of chars
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Sep 16, 2019
1 parent 4f2301c commit 2870d07
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion modules/security/src/main/FingerPrint.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@ object FingerHash {
import org.apache.commons.codec.binary.Hex
FingerHash {
Base64.getEncoder encodeToString {
Hex decodeHex print.value.replace("-", "").toArray
Hex decodeHex normalize(print).toArray
} take length
} some
} catch {
case _: Exception => none
}

private def normalize(fp: FingerPrint): String = {
val str = fp.value.replace("-", "")
if (str.size % 2 == 1) s"${str}0" else str
}

val impersonate = FingerHash("imperson")

implicit val fingerHashIso = Iso.string[FingerHash](FingerHash.apply, _.value)
Expand Down

0 comments on commit 2870d07

Please sign in to comment.