Created
February 9, 2019 07:45
-
-
Save andrew-wilkes/6537f4510e9721cf0f3496161c283197 to your computer and use it in GitHub Desktop.
Test code for text obfuscation methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Node2D | |
func _ready(): | |
var test_bytes = generate_test_bytes() | |
var processed_bytes = flip_bytes(flip_bytes(test_bytes)) | |
print(compare_bytes(test_bytes, processed_bytes)) | |
func generate_test_bytes() -> PoolByteArray: | |
var bytes = [] as PoolByteArray | |
for i in range(256): | |
bytes.append(i) | |
return bytes | |
func flip_bytes(bytes: PoolByteArray): | |
var s = "" | |
for i in bytes.size(): | |
bytes[i] = flip_byte(bytes[i]) | |
s += String(bytes[i]) + " " | |
print(s) | |
return bytes | |
func flip_byte(b: int) -> int: | |
return b ^ 7 | |
#return b * -1 | |
func compare_bytes(b1: PoolByteArray, b2: PoolByteArray): | |
var result = 0 | |
for i in b1.size(): | |
if b1[i] != b2[i]: | |
print("%d != %d" % [b1[i], b2[i]]) | |
result = 1 | |
return ["OK", "FAILED"][result] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment