Skip to content

Instantly share code, notes, and snippets.

@andrew-wilkes
Created February 8, 2019 14:26
Show Gist options
  • Save andrew-wilkes/ae55448bd23a6d3518fd776202ec8bac to your computer and use it in GitHub Desktop.
Save andrew-wilkes/ae55448bd23a6d3518fd776202ec8bac to your computer and use it in GitHub Desktop.
Godot simple text file obfuscation
var d = File.new()
if d.file_exists(DIALOG_FILE):
encode_dialog()
d.open(ENC_DIALOG_FILE, File.READ)
dialog = flip_bytes(d.get_buffer(d.get_len())).get_string_from_utf8().split("###")
d.close()
func encode_dialog():
var file = File.new()
file.open(DIALOG_FILE, File.READ)
var text = file.get_as_text()
file.close()
file.open(ENC_DIALOG_FILE, File.WRITE)
var p = flip_bytes(text.to_utf8())
file.store_buffer(p)
file.close()
func flip_bytes(p):
for i in p.size():
p[i] *= -1
return p
@andrew-wilkes
Copy link
Author

Oh, and in my system, there is a delimiter of "###" between sections of text to allow them to be parsed into an array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment