This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
teamcity-gitea-test-task/src/main/kotlin/tinyvm/Object.kt
Gleb Koval 7233a7e8d1
All checks were successful
Publish Workflow / Publish library (push) Successful in 8m28s
Test Workflow / Lint and test library (push) Successful in 16m51s
Cleanup and privatise commit comparator
2023-12-05 02:00:35 +00:00

17 lines
402 B
Kotlin

package tinyvm
import java.security.MessageDigest
import java.util.HexFormat
/**
* Represents an arbitrary version manager object.
*/
abstract class Object(val type: String) {
abstract val data: String
fun hash(): String =
HexFormat.of().formatHex(
MessageDigest.getInstance("SHA-1")
.digest("$type ${data.length}\u0000$data".toByteArray()),
)
}