Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encrypt/Decrypt string variable with GDscript #1969

Closed
volzhs opened this issue May 24, 2015 · 11 comments
Closed

Encrypt/Decrypt string variable with GDscript #1969

volzhs opened this issue May 24, 2015 · 11 comments

Comments

@volzhs
Copy link
Contributor

volzhs commented May 24, 2015

It would be great to have simple way for encrypt/decrypt string like this.

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

I think it's very useful when send/receive some messages over network.

@reduz
Copy link
Member

reduz commented May 24, 2015

could use aes256 for this, would that be fine?

On Sun, May 24, 2015 at 11:40 AM, volzhs notifications@github.com wrote:

It would be great to have simple way for encrypt/decrypt string like this.

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

I think it's very useful when send/receive some messages over network.


Reply to this email directly or view it on GitHub
#1969.

@volzhs
Copy link
Contributor Author

volzhs commented May 24, 2015

Yes! I love it. That would be great~ 👍

@kubecz3k kubecz3k changed the title [Feature Request] Encrypt/Decrypt string variable with GDscript Encrypt/Decrypt string variable with GDscript Nov 13, 2015
@gau-veldt
Copy link
Contributor

Over networks you probably want a Diffie Hellman key exchange to prevent MITM sniffing of the keys used to encrypt passwords.

@Catprog
Copy link

Catprog commented Aug 17, 2017

Currently I am traveling so can't update the branch.

Last I heard the discussion was over the api.

Here are the functions that are needed:

  • Set password / Set Key

password sha256 hashes the input and puts it into the key.
key pads the key to 32 bytes(and hashes it into 32 bytes if longer)

-Use hmac

Is their a hmac at the start of the message(works for encrypting and decryption)

-encrypt_raw
-encrypt_string
-decrypt_raw
-decrypt_string

The meat of the class.
encrypting always returns a char array
decryption always takes a char array
string and raw refers to the type of input and output.

Could someone provide me with a suitable api that I can implement when I get home?

@blurymind
Copy link

this would be very nice to have for encrypting game saves or for implementing anti-piracy measures

@StraToN
Copy link
Member

StraToN commented Oct 5, 2018

If possible, it would be interesting to provide the same functionalities with other algorithms, such as sha-512.

@gau-veldt
Copy link
Contributor

gau-veldt commented Oct 5, 2018

@StraToN However the SHA family of algorithms are for one-way (non-reversible) hashes (digital signatures, integrity checks, etc.) and not for actual encryption of messages and data. For instance passwords could be stored locally using an SHA algorithm but transmission of passwords (insecure) to reply to a host's credential challenge needs to use a (reversible) cipher.

@Calinou
Copy link
Member

Calinou commented Oct 5, 2018

@StraToN There's already String.sha256_buffer(), String.sha256_text() and File.get_sha256() (in addition to their md5 counterparts).

For instance passwords could be stored locally using an SHA algorithm

Passwords should be hashed using a strong algorithm that's slow to compute, such as bcrypt or Argon2 😃

@gau-veldt
Copy link
Contributor

gau-veldt commented Oct 5, 2018

Are BSD's & linuxes now doing this by default?
Is there a feature proposal to add these alongside String.sha256_buffer() and friends?

On the same note as this very feature request, the absence of them in the API pretty much precludes their use in a Godot project unless perhaps one is a C++ whiz using Godot 3 and wants to make a GDNative plugin (but that creates in itself new issues such as platform dependence).

@Malkverbena
Copy link

I got some work to expose the mbedtls functions. Could maybe some of these functions be used in Godot?
Maybe merged on GDscript?
I don't know which way to go and I also don't know intimately the internal mechanisms of Godot.

https://github.com/Malkverbena/cripter

@akien-mga
Copy link
Member

Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine.

The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker.

If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance!

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

No branches or pull requests

10 participants