How do I fix my error?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Artifabrian

I tried using the save_encrypted() instead of just save(), and I get the error: Cannot pass a value of type "String" as "PackedByteArray. Unfortunately, I have no idea how to fix this, so I would appreciate any help possible. Thank you!

:bust_in_silhouette: Reply From: carlosjorgereis

save_encrypted(arg1,arg2)
arg1 = file you want to save. ie: “user://gamedata.dat”
arg2 = password. ie: “mypassword”

I am still getting the same error, I think it is because arg2 is a string and not a packed byte array (because I think that is what the error is saying), and I don’t know how to convert a string to a packed byte array.

Artifabrian | 2023-04-08 17:19

:bust_in_silhouette: Reply From: jgodfrey

If you want to encrypt the file with a string-based password, use save_encrypted_pass() instead. So, something like…

save_encrypted_pass("user://gamedata.dat", "your_password")