diff --git a/archive/src/main/kotlin/org/openrs2/archive/key/EntCommand.kt b/archive/src/main/kotlin/org/openrs2/archive/key/EntCommand.kt
index 2b328eb5..ac1f1519 100644
--- a/archive/src/main/kotlin/org/openrs2/archive/key/EntCommand.kt
+++ b/archive/src/main/kotlin/org/openrs2/archive/key/EntCommand.kt
@@ -5,33 +5,12 @@ import com.google.inject.Guice
import kotlinx.coroutines.runBlocking
import org.openrs2.archive.ArchiveModule
import org.openrs2.inject.CloseableInjector
-import java.io.BufferedOutputStream
-import java.io.DataOutputStream
public class EntCommand : CliktCommand(name = "ent") {
override fun run(): Unit = runBlocking {
CloseableInjector(Guice.createInjector(ArchiveModule)).use { injector ->
val exporter = injector.getInstance(KeyExporter::class.java)
- val keys = exporter.exportValid()
-
- val process = ProcessBuilder("ent")
- .redirectOutput(ProcessBuilder.Redirect.INHERIT)
- .redirectError(ProcessBuilder.Redirect.INHERIT)
- .start()
-
- DataOutputStream(BufferedOutputStream(process.outputStream)).use { out ->
- for (key in keys) {
- out.writeInt(key.k0)
- out.writeInt(key.k1)
- out.writeInt(key.k2)
- out.writeInt(key.k3)
- }
- }
-
- val status = process.waitFor()
- if (status != 0) {
- throw Exception("ent failed: $status")
- }
+ println(exporter.analyse())
}
}
}
diff --git a/archive/src/main/kotlin/org/openrs2/archive/key/KeyExporter.kt b/archive/src/main/kotlin/org/openrs2/archive/key/KeyExporter.kt
index f41b0d65..5d7526d4 100644
--- a/archive/src/main/kotlin/org/openrs2/archive/key/KeyExporter.kt
+++ b/archive/src/main/kotlin/org/openrs2/archive/key/KeyExporter.kt
@@ -2,6 +2,8 @@ package org.openrs2.archive.key
import org.openrs2.crypto.XteaKey
import org.openrs2.db.Database
+import java.io.BufferedOutputStream
+import java.io.DataOutputStream
import javax.inject.Inject
import javax.inject.Singleton
@@ -77,6 +79,32 @@ public class KeyExporter @Inject constructor(
return export(validOnly = true)
}
+ public suspend fun analyse(): String {
+ val keys = exportValid()
+
+ val process = ProcessBuilder("ent")
+ .redirectError(ProcessBuilder.Redirect.INHERIT)
+ .start()
+
+ DataOutputStream(BufferedOutputStream(process.outputStream)).use { out ->
+ for (key in keys) {
+ out.writeInt(key.k0)
+ out.writeInt(key.k1)
+ out.writeInt(key.k2)
+ out.writeInt(key.k3)
+ }
+ }
+
+ val analysis = process.inputStream.readAllBytes().toString(Charsets.UTF_8)
+
+ val status = process.waitFor()
+ if (status != 0) {
+ throw Exception("ent failed: $status")
+ }
+
+ return analysis
+ }
+
private suspend fun export(validOnly: Boolean): List
This page allows all raw keys in the database to be exported in @@ -37,12 +38,26 @@ the cache, use the download link on the caches page instead.
- + + +
+ The output of piping all validated keys in binary format into
+ ent
+ is:
+
+
+ The keys are sorted in import order, which does not match the
+ order they were generated in. This could influence portions of
+ ent
's output.
+