summaryrefslogtreecommitdiff
path: root/doc/classes/AESContext.xml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/classes/AESContext.xml')
-rw-r--r--doc/classes/AESContext.xml32
1 files changed, 16 insertions, 16 deletions
diff --git a/doc/classes/AESContext.xml b/doc/classes/AESContext.xml
index 747968ea91..bbea8535bb 100644
--- a/doc/classes/AESContext.xml
+++ b/doc/classes/AESContext.xml
@@ -15,27 +15,27 @@
var key = "My secret key!!!" # Key must be either 16 or 32 bytes.
var data = "My secret text!!" # Data size must be multiple of 16 bytes, apply padding if needed.
# Encrypt ECB
- aes.start(AESContext.MODE_ECB_ENCRYPT, key.to_utf8())
- var encrypted = aes.update(data.to_utf8())
+ aes.start(AESContext.MODE_ECB_ENCRYPT, key.to_utf8_buffer())
+ var encrypted = aes.update(data.to_utf8_buffer())
aes.finish()
# Decrypt ECB
- aes.start(AESContext.MODE_ECB_DECRYPT, key.to_utf8())
+ aes.start(AESContext.MODE_ECB_DECRYPT, key.to_utf8_buffer())
var decrypted = aes.update(encrypted)
aes.finish()
# Check ECB
- assert(decrypted == data.to_utf8())
+ assert(decrypted == data.to_utf8_buffer())
var iv = "My secret iv!!!!" # IV must be of exactly 16 bytes.
# Encrypt CBC
- aes.start(AESContext.MODE_CBC_ENCRYPT, key.to_utf8(), iv.to_utf8())
- encrypted = aes.update(data.to_utf8())
+ aes.start(AESContext.MODE_CBC_ENCRYPT, key.to_utf8_buffer(), iv.to_utf8_buffer())
+ encrypted = aes.update(data.to_utf8_buffer())
aes.finish()
# Decrypt CBC
- aes.start(AESContext.MODE_CBC_DECRYPT, key.to_utf8(), iv.to_utf8())
+ aes.start(AESContext.MODE_CBC_DECRYPT, key.to_utf8_buffer(), iv.to_utf8_buffer())
decrypted = aes.update(encrypted)
aes.finish()
# Check CBC
- assert(decrypted == data.to_utf8())
+ assert(decrypted == data.to_utf8_buffer())
[/gdscript]
[csharp]
using Godot;
@@ -50,27 +50,27 @@
string key = "My secret key!!!"; // Key must be either 16 or 32 bytes.
string data = "My secret text!!"; // Data size must be multiple of 16 bytes, apply padding if needed.
// Encrypt ECB
- _aes.Start(AesContext.Mode.EcbEncrypt, key.ToUtf8());
- byte[] encrypted = _aes.Update(data.ToUtf8());
+ _aes.Start(AesContext.Mode.EcbEncrypt, key.ToUtf8Buffer());
+ byte[] encrypted = _aes.Update(data.ToUtf8Buffer());
_aes.Finish();
// Decrypt ECB
- _aes.Start(AesContext.Mode.EcbDecrypt, key.ToUtf8());
+ _aes.Start(AesContext.Mode.EcbDecrypt, key.ToUtf8Buffer());
byte[] decrypted = _aes.Update(encrypted);
_aes.Finish();
// Check ECB
- Debug.Assert(decrypted == data.ToUtf8());
+ Debug.Assert(decrypted == data.ToUtf8Buffer());
string iv = "My secret iv!!!!"; // IV must be of exactly 16 bytes.
// Encrypt CBC
- _aes.Start(AesContext.Mode.EcbEncrypt, key.ToUtf8(), iv.ToUtf8());
- encrypted = _aes.Update(data.ToUtf8());
+ _aes.Start(AesContext.Mode.EcbEncrypt, key.ToUtf8Buffer(), iv.ToUtf8Buffer());
+ encrypted = _aes.Update(data.ToUtf8Buffer());
_aes.Finish();
// Decrypt CBC
- _aes.Start(AesContext.Mode.EcbDecrypt, key.ToUtf8(), iv.ToUtf8());
+ _aes.Start(AesContext.Mode.EcbDecrypt, key.ToUtf8Buffer(), iv.ToUtf8Buffer());
decrypted = _aes.Update(encrypted);
_aes.Finish();
// Check CBC
- Debug.Assert(decrypted == data.ToUtf8());
+ Debug.Assert(decrypted == data.ToUtf8Buffer());
}
}
[/csharp]