Created
November 17, 2017 16:20
-
-
Save pavlo/d0ee6eb63484646c6334bb66c112976d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.commons.lang3.RandomStringUtils; | |
public class TokenService { | |
public String createToken(int playbackPosition) { | |
String suffix = RandomStringUtils.randomAlphanumeric(16); | |
return String.valueOf(playbackPosition) + ":" + suffix; | |
} | |
public int tokenToPlaybackIndex(String token) { | |
String positionStr = token.split(":")[0]; | |
return Integer.valueOf(positionStr); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment