Skip to content

Instantly share code, notes, and snippets.

@pavlo
Created November 17, 2017 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pavlo/d0ee6eb63484646c6334bb66c112976d to your computer and use it in GitHub Desktop.
Save pavlo/d0ee6eb63484646c6334bb66c112976d to your computer and use it in GitHub Desktop.
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