summaryrefslogtreecommitdiff
path: root/plugin/src/main/kotlin/moe/nea/archenemy/util/DigestUtils.kt
blob: d2de936a7848e07fb74748cb714b5a497e81250b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package moe.nea.archenemy.util

import org.gradle.api.artifacts.ModuleDependency
import java.security.MessageDigest

fun MessageDigest.updateField(text: String, value: String) {
    this.update(text)
    this.update(":")
    this.update(value)
    this.update(";")
}

fun MessageDigest.update(text: String) {
    this.update(text.encodeToByteArray())
}

fun MessageDigest.updateGMV(name: String, moduleDependency: ModuleDependency) {
    this.updateField(
        name,
        (moduleDependency.group ?: "") + ":" + moduleDependency.name + ":" + (moduleDependency.version ?: "")
    )
}