mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2026-04-20 01:27:02 -04:00
30 lines
962 B
Groovy
30 lines
962 B
Groovy
import java.security.MessageDigest
|
|
|
|
plugins{
|
|
id 'com.android.application' version '8.7.2' apply false
|
|
id 'com.android.library' version '8.7.2' apply false
|
|
}
|
|
|
|
static void hashFileWithDigest(File fileToHash, MessageDigest digest){
|
|
fileToHash.withInputStream { is ->
|
|
byte[] buffer = new byte[8192]
|
|
int read
|
|
while ((read = is.read(buffer)) != -1) {
|
|
digest.update(buffer, 0, read)
|
|
}
|
|
}
|
|
}
|
|
|
|
static void writeVersionFile(File jarFile, File versionFile){
|
|
def sha1 = MessageDigest.getInstance("SHA-1")
|
|
hashFileWithDigest(jarFile, sha1)
|
|
versionFile.write(sha1.digest().collect { String.format("%02x", it) }.join())
|
|
}
|
|
|
|
static void writeVersionFile(File[] jarFileArray, File versionFile){
|
|
def sha1 = MessageDigest.getInstance("SHA-1")
|
|
jarFileArray.each {jarFile ->
|
|
hashFileWithDigest(jarFile, sha1)
|
|
}
|
|
versionFile.write(sha1.digest().collect { String.format("%02x", it) }.join())
|
|
} |