aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/Utils.kt')
-rw-r--r--src/Utils.kt13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Utils.kt b/src/Utils.kt
new file mode 100644
index 0000000..acfb72a
--- /dev/null
+++ b/src/Utils.kt
@@ -0,0 +1,13 @@
+import java.io.File
+import java.math.BigInteger
+import java.security.MessageDigest
+
+/**
+ * Reads lines from the given input txt file.
+ */
+fun readInput(name: String) = File("src", "$name.txt").readLines()
+
+/**
+ * Converts string to md5 hash.
+ */
+fun String.md5(): String = BigInteger(1, MessageDigest.getInstance("MD5").digest(toByteArray())).toString(16)