godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.1k stars 69 forks source link

Add Encrypt/Decrypt string methods #2128

Open golddotasksquestions opened 3 years ago

golddotasksquestions commented 3 years ago

Describe the project you are working on

I am looking for a simple method to decrypt and encrypt strings in GDScript. This has been requested before https://github.com/godotengine/godot/issues/1969 (since 2015) https://github.com/godotengine/godot/pull/5868

Describe the problem or limitation you are having in your project

Currently we have the the Crypto class, and the possibility to encrypt files while writing them, but neither of those seem to provide simple string encryption, at least not in a straight forward that would be very intuitive or simple enough for a beginner. Also I don't want to create and write, open and read a file every time I just want to encrypt/decrypt a string.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

It would make a simple string encryption a lot easier, and while this has it's limitations, it would provide a point of entry for beginners and make the learning curve for encryption and security more gentle.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

var message = "1234abcd"
var rawarray_encrypted_str = encrypt(message,"key")
var message_decrypted = decrypt(rawarray_encrypted_str, "key")

The keycan be a crypthographic RSA key generated with Crypto and CryptoKey class, but imho should not need to be.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Writing a decrypting and encrypting method for a string is not something anyone could do easily with a few lines.

Is there a reason why this should be core and not an add-on in the asset library?

It's a GDScript feature request.

aaronfranke commented 3 years ago

Is there a reason why this should be core and not an add-on in the asset library?

It's a GDScript feature request.

You can create your own methods in GDScript. I don't see a reason why this can't be done with an add-on.

dalexeev commented 3 years ago

Currently we have the the Crypto class, and the possibility to encrypt files while writing them, but neither of those seem to provide simple string encryption

See also: #201

The File class has open, open_compressed, open_encrypted and open_encrypted_with_pass methods, but it only allow you to work with files in the file system, not in memory.

PrinceMerluza commented 3 years ago

Honestly surprised that 4.0 is around the corner and we still can't get a simple string encryption smh.

Calinou commented 3 years ago

@PrinceMerluza Please don't bump issues without contributing significant new information. Use the :+1: reaction button on the first post instead.

aanishacharyaa commented 2 years ago

much needed functionality.

Calinou commented 2 years ago

@aanishacharyaa Please don't bump issues without contributing significant new information. Use the :+1: reaction button on the first post instead.