Answer the question
In order to leave comments, you need to log in
How to protect some text in a scripting programming language?
Hello! Very weak in the topic of storing data safely. The bottom line is that you need to hide a couple of dozen lines of text from the player. So that he could not know the answer in advance.
And I don’t really want to make connection elements to the web server because of this. What’s more, it doesn’t really help either.
The problem is that it will be used as a scripting language. In Python or Lua (Love2d).
An option to make some kind of binary? Compiled language. I'm not sure that this will save, just as I don't understand how it is safe to get a string from a scripting language in a compiled one.
Any ideas about this? Thanks in advance.
Answer the question
In order to leave comments, you need to log in
Store the hash of the correct answer and compare with the hash of the entered value.
The simplest - base64 encoding / decoding - will no longer be readable text in the code:
import base64
xoxoxo = b'0J/RgNC40LLQtdGCLCDQotC+0YHRgtC10YAh'
decoded = base64.b64decode(xoxoxo).decode('utf-8')
# Привет, Тостер!
>>> source = 'Привет, Тостер!'
>>> bytes = source.encode('utf-8')
>>> xoxoxo = base64.b64encode(bytes)
The strings in the binary will still be in the clear, and if you encrypt them using a dictionary, then nothing will be clear without parsing the source code.
>>> text = "encoded message"
>>> E = " ,[email protected]#$%^&*()"+"".join([chr(x)for x in list(range(ord('A'),ord('Z')+1))+list(range(ord('a'),ord('z')+1))])
>>> E
' ,[email protected]#$%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
>>> encoded_text = "+".join(["E[%d]"%E.index(t) for t in text])
>>> encoded_text
'E[44]+E[53]+E[42]+E[54]+E[43]+E[44]+E[43]+E[0]+E[52]+E[44]+E[58]+E[58]+E[40]+E[46]+E[44]'
>>> eval(encoded_text)
'encoded message'
>>>
E = ' ,[email protected]#$%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
text1=E[44]+E[53]+E[42]+E[54]+E[43]+E[44]+E[43]+E[0]+E[52]+E[44]+E[58]+E[58]+E[40]+E[46]+E[44]
text2=E[23]+E[60]+E[58]+E[59]+E[0]+E[45]+E[54]+E[57]+E[0]+E[33]+E[18]+E[32]+E[33]+E[0]+E[64]+E[54]+E[60]+E[0]+E[52]+E[48]+E[53]+E[43]+E[4]
Lua compiles to binary
https://stackoverflow.com/questions/194520/creatin...
Python - compiles to custom command set
Scripting languages lend themselves to obfuscation, look in this direction, otherwise it’s better to write a module, of course, but modules can also have their own craftsmen. )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question