diff --git a/hashids-scala/src/main/scala/org/hashids/impl/package.scala b/hashids-scala/src/main/scala/org/hashids/impl/package.scala index 82f660f..7b6a5c3 100644 --- a/hashids-scala/src/main/scala/org/hashids/impl/package.scala +++ b/hashids-scala/src/main/scala/org/hashids/impl/package.scala @@ -43,8 +43,8 @@ package object impl { } def unhash(input: String, alphabet: String): Long = { - input.zipWithIndex.foldLeft[Long](0L) { case (acc, (in, i)) => - acc + (alphabet.indexOf(in) * Math.pow(alphabet.length, input.length - 1 - i)).toLong + input.foldLeft[Long](0L) { + (carry, item) => carry * alphabet.length + alphabet.indexOf(item) } }