Open-source multiplayer game server compatible with the RuneScape client
https://www.openrs2.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
846 B
31 lines
846 B
package org.openrs2.crc32
|
|
|
|
import com.github.ajalt.clikt.core.CliktCommand
|
|
import com.github.ajalt.clikt.parameters.options.option
|
|
import com.github.ajalt.clikt.parameters.types.defaultStdin
|
|
import com.github.ajalt.clikt.parameters.types.inputStream
|
|
import java.util.zip.CRC32
|
|
|
|
public fun main(args: Array<String>): Unit = Crc32Command().main(args)
|
|
|
|
public class Crc32Command : CliktCommand(name = "crc32") {
|
|
private val input by option().inputStream().defaultStdin()
|
|
|
|
override fun run() {
|
|
val crc = CRC32()
|
|
val bytes = ByteArray(4096)
|
|
|
|
input.use { input ->
|
|
while (true) {
|
|
val len = input.read(bytes)
|
|
if (len == -1) {
|
|
break
|
|
}
|
|
|
|
crc.update(bytes, 0, len)
|
|
}
|
|
}
|
|
|
|
echo(crc.value.toInt())
|
|
}
|
|
}
|
|
|