Created
December 3, 2018 09:33
-
-
Save phstudy/af1c9c9859808eaf06adec60af5c4072 to your computer and use it in GitHub Desktop.
calculate SAPISIDDASH
This file contains hidden or 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 com.google.common.hash.Hashing; | |
import java.nio.charset.Charset; | |
public class GoogleTokenUtils { | |
public static String calcSapiSidDash(long ts, String sapiSid, String origin) { | |
return String.format("%d_%s", ts, calcHash(ts, sapiSid, origin)); | |
} | |
public static String calcSapiSidDash(String sapiSid, String origin) { | |
long ts = System.currentTimeMillis(); | |
return calcSapiSidDash(ts, sapiSid, origin); | |
} | |
private static String calcHash(long ts, String sapiSid, String origin) { | |
String plain = String.format("%d %s %s", ts, sapiSid, origin); | |
return Hashing.sha1().hashString(plain, Charset.defaultCharset()).toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment