Last active
April 26, 2017 15:27
-
-
Save timkrins/16e16dec94e23ad2749bcc9ca3c05e70 to your computer and use it in GitHub Desktop.
Facebook Hash Generator for Android Gradle Console
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
def getFacebookHash = { -> | |
try { | |
def stdOut = new ByteArrayOutputStream() | |
def stdIn = new ByteArrayInputStream() | |
exec { | |
commandLine "keytool", "-exportcert", "-alias", KEY_ALIAS, "-keystore", file(STORE_FILE), "-storepass", STORE_PASSWORD | |
standardOutput = stdOut | |
} | |
stdIn = new ByteArrayInputStream(stdOut.toByteArray()) | |
stdOut = new ByteArrayOutputStream() | |
exec { | |
standardInput = stdIn | |
commandLine file(OPENSSL_BINARY), "sha1", "-binary" | |
standardOutput = stdOut | |
} | |
stdIn = new ByteArrayInputStream(stdOut.toByteArray()) | |
stdOut = new ByteArrayOutputStream() | |
exec { | |
standardInput = stdIn | |
commandLine file(OPENSSL_BINARY), "base64" | |
standardOutput = stdOut | |
} | |
def hashString = stdOut.toString().trim() | |
return hashString | |
} | |
catch (error) { | |
return error.toString(); | |
} | |
} | |
gradle.buildFinished { | |
println "Facebook Release Key Hash:\n " + getFacebookHash() + "\n" | |
} |
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
STORE_FILE=C:/Keystore.jks | |
STORE_PASSWORD=password | |
KEY_ALIAS=keystoreAlias | |
KEY_PASSWORD=password | |
OPENSSL_BINARY=C:/OpenSSL-Win64/bin/openssl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment