Documentation ¶
Overview ¶
Package AESContext provides methods for working with AESContext object instances.
Index ¶
- type Advanced
- type Any
- type Error
- type Instance
- func (self Instance) AsAESContext() Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) Finish()
- func (self Instance) GetIvState() []byte
- func (self Instance) Start(mode gdclass.AESContextMode, key []byte) error
- func (self *Instance) UnsafePointer() unsafe.Pointer
- func (self Instance) Update(src []byte) []byte
- func (self Instance) Virtual(name string) reflect.Value
- type Mode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Error ¶
const ( /*Methods that return [enum Error] return [constant OK] when no error occurred. Since [constant OK] has value 0, and all other error constants are positive integers, it can also be used in boolean checks. [b]Example:[/b] [codeblock] var error = method_that_returns_error() if error != OK: printerr("Failure!") # Or, alternatively: if error: printerr("Still failing!") [/codeblock] [b]Note:[/b] Many functions do not return an error code, but will print error messages to standard output.*/ Ok Error = 0 /*Generic error.*/ Failed Error = 1 ErrUnavailable Error = 2 /*Unconfigured error.*/ ErrUnconfigured Error = 3 ErrUnauthorized Error = 4 /*Parameter range error.*/ ErrParameterRangeError Error = 5 /*Out of memory (OOM) error.*/ ErrOutOfMemory Error = 6 /*File: Not found error.*/ ErrFileNotFound Error = 7 /*File: Bad drive error.*/ ErrFileBadDrive Error = 8 /*File: Bad path error.*/ ErrFileBadPath Error = 9 /*File: No permission error.*/ ErrFileNoPermission Error = 10 /*File: Already in use error.*/ ErrFileAlreadyInUse Error = 11 /*File: Can't open error.*/ ErrFileCantOpen Error = 12 /*File: Can't write error.*/ ErrFileCantWrite Error = 13 /*File: Can't read error.*/ ErrFileCantRead Error = 14 /*File: Unrecognized error.*/ ErrFileUnrecognized Error = 15 /*File: Corrupt error.*/ ErrFileCorrupt Error = 16 /*File: Missing dependencies error.*/ ErrFileMissingDependencies Error = 17 /*File: End of file (EOF) error.*/ ErrFileEof Error = 18 /*Can't open error.*/ ErrCantOpen Error = 19 /*Can't create error.*/ ErrCantCreate Error = 20 /*Query failed error.*/ ErrQueryFailed Error = 21 /*Already in use error.*/ ErrAlreadyInUse Error = 22 /*Locked error.*/ ErrLocked Error = 23 /*Timeout error.*/ ErrTimeout Error = 24 /*Can't connect error.*/ ErrCantConnect Error = 25 /*Can't resolve error.*/ ErrCantResolve Error = 26 /*Connection error.*/ ErrConnectionError Error = 27 /*Can't acquire resource error.*/ ErrCantAcquireResource Error = 28 /*Can't fork process error.*/ ErrCantFork Error = 29 /*Invalid data error.*/ ErrInvalidData Error = 30 /*Invalid parameter error.*/ ErrInvalidParameter Error = 31 /*Already exists error.*/ ErrAlreadyExists Error = 32 /*Does not exist error.*/ ErrDoesNotExist Error = 33 /*Database: Read error.*/ ErrDatabaseCantRead Error = 34 /*Database: Write error.*/ ErrDatabaseCantWrite Error = 35 /*Compilation failed error.*/ ErrCompilationFailed Error = 36 /*Method not found error.*/ ErrMethodNotFound Error = 37 /*Linking failed error.*/ ErrLinkFailed Error = 38 /*Script failed error.*/ ErrScriptFailed Error = 39 /*Cycling link (import cycle) error.*/ ErrCyclicLink Error = 40 /*Invalid declaration error.*/ ErrInvalidDeclaration Error = 41 /*Duplicate symbol error.*/ ErrDuplicateSymbol Error = 42 /*Parse error.*/ ErrParseError Error = 43 /*Busy error.*/ ErrBusy Error = 44 /*Skip error.*/ ErrSkip Error = 45 /*Help error. Used internally when passing [code]--version[/code] or [code]--help[/code] as executable options.*/ ErrHelp Error = 46 /*Bug error, caused by an implementation issue in the method. [b]Note:[/b] If a built-in method returns this code, please open an issue on [url=https://github.com/godotengine/godot/issues]the GitHub Issue Tracker[/url].*/ ErrBug Error = 47 /*Printer on fire error (This is an easter egg, no built-in methods return this error code).*/ ErrPrinterOnFire Error = 48 )
type Instance ¶
type Instance [1]gdclass.AESContext
This class holds the context information required for encryption and decryption operations with AES (Advanced Encryption Standard). Both AES-ECB and AES-CBC modes are supported. [codeblocks] [gdscript] extends Node
var aes = AESContext.new()
func _ready():
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_buffer()) var encrypted = aes.update(data.to_utf8_buffer()) aes.finish() # Decrypt ECB aes.start(AESContext.MODE_ECB_DECRYPT, key.to_utf8_buffer()) var decrypted = aes.update(encrypted) aes.finish() # Check ECB 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_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_buffer(), iv.to_utf8_buffer()) decrypted = aes.update(encrypted) aes.finish() # Check CBC assert(decrypted == data.to_utf8_buffer())
[/gdscript] [csharp] using Godot; using System.Diagnostics;
public partial class MyNode : Node
{ private AesContext _aes = new AesContext(); public override void _Ready() { 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.ToUtf8Buffer()); byte[] encrypted = _aes.Update(data.ToUtf8Buffer()); _aes.Finish(); // Decrypt ECB _aes.Start(AesContext.Mode.EcbDecrypt, key.ToUtf8Buffer()); byte[] decrypted = _aes.Update(encrypted); _aes.Finish(); // Check ECB 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.ToUtf8Buffer(), iv.ToUtf8Buffer()); encrypted = _aes.Update(data.ToUtf8Buffer()); _aes.Finish(); // Decrypt CBC _aes.Start(AesContext.Mode.EcbDecrypt, key.ToUtf8Buffer(), iv.ToUtf8Buffer()); decrypted = _aes.Update(encrypted); _aes.Finish(); // Check CBC Debug.Assert(decrypted == data.ToUtf8Buffer()); } }
[/csharp] [/codeblocks]
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsAESContext ¶
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) Finish ¶
func (self Instance) Finish()
Close this AES context so it can be started again. See [method start].
func (Instance) GetIvState ¶
Get the current IV state for this context (IV gets updated when calling [method update]). You normally don't need this function. [b]Note:[/b] This function only makes sense when the context is started with [constant MODE_CBC_ENCRYPT] or [constant MODE_CBC_DECRYPT].
func (Instance) Start ¶
func (self Instance) Start(mode gdclass.AESContextMode, key []byte) error
Start the AES context in the given [param mode]. A [param key] of either 16 or 32 bytes must always be provided, while an [param iv] (initialization vector) of exactly 16 bytes, is only needed when [param mode] is either [constant MODE_CBC_ENCRYPT] or [constant MODE_CBC_DECRYPT].
func (*Instance) UnsafePointer ¶
func (Instance) Update ¶
Run the desired operation for this AES context. Will return a [PackedByteArray] containing the result of encrypting (or decrypting) the given [param src]. See [method start] for mode of operation. [b]Note:[/b] The size of [param src] must be a multiple of 16. Apply some padding if needed.
type Mode ¶
type Mode = gdclass.AESContextMode //gd:AESContext.Mode
const ( /*AES electronic codebook encryption mode.*/ ModeEcbEncrypt Mode = 0 /*AES electronic codebook decryption mode.*/ ModeEcbDecrypt Mode = 1 /*AES cipher blocker chaining encryption mode.*/ ModeCbcEncrypt Mode = 2 /*AES cipher blocker chaining decryption mode.*/ ModeCbcDecrypt Mode = 3 /*Maximum value for the mode enum.*/ ModeMax Mode = 4 )