Skip to content

Instantly share code, notes, and snippets.

@fxlae
fxlae / SteamTOTPConverter.scala
Last active August 29, 2015 14:25
A sample implementation for mapping 10 digit TOTP tokens to 5 digit tokens that are accepted by Steam.
object SteamTOTPConverter {
private val base26Chars = "0123456789ABCDEFGHIJKLMNOP"
private val steamChars = "23456789BCDFGHJKMNPQRTVWXY"
private val charMap = (base26Chars zip steamChars) toMap
private def toBase26(number: Int) = Integer.toString(number, 26).toUpperCase
def convertFrom(totpToken: Int) = {
toBase26(totpToken)
.takeRight(5)