How to encrypt a script

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By I reject all deals

How to encryp a string in godot?
I know how to save a string to file with encrypting but I dont know how to do it without saving any file. Is there is any way?

:bust_in_silhouette: Reply From: jgodfrey

Depending on the details of your use-case, there are a number of cryptographic’ish methods available for the String class. For example, hash(), md5_text(), sha1_text(), and sha256_text(). All will allow you to convert a plain-text string into some form of hashed representation…

Maybe one of those will suit your needs?

String docs here:

Thank you. But for example I used md5_text for encrypting, how I will decrypt again amd get the original text?

I reject all deals | 2023-05-28 17:23

Most hashing algorithms (including MD5) are not intended to be “reversed”. So, there’s no reasonable way of retrieving the original text from an MD5 hash.

For a reversable mechanism, you might take a look as AES. The docs show an example of both encryption and decryption.

AESContext — Godot Engine (3.5) documentation in English

jgodfrey | 2023-05-28 18:12