Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
AESContext¶
Interfaz para las características de encriptación AES de bajo nivel.
Descripción¶
Esta clase proporciona acceso a la encriptación/desencriptación AES de los datos en bruto. Tanto el modo AES-ECB como el AES-CBC están soportados.
extends Node
var aes = AESContext.new()
func _ready():
var clave = "Mi clave secreta!!!" # La clave debe ser de 16 o 32 bytes. (1 byte = 1 char) normalmdlkd
var datos = "Mi clave secreta" # El tamaño de datos debe ser multiplo de 16, ponga algún relleno para completar de ser necesario.
# Encriptar ECB
aes.start(AESContext.MODE_ECB_ENCRYPT, clave.to_utf8())
var encriptado = aes.update(datos.to_utf8())
aes.finish()
# Desencriptar ECB
aes.start(AESContext.MODE_ECB_DECRYPT, clave.to_utf8())
var desencriptado = aes.update(encriptado)
aes.finish()
# Comprobar ECB
assert(desencriptado == datos.to_utf8())
var iv = "Mi secreto iv!!!" # IV debe ser de tamaño 16 bytes.
# Encriptar CBC
aes.start(AESContext.MODE_CBC_ENCRYPT, clave.to_utf8(), iv.to_utf8())
encriptado = aes.update(datos.to_utf8())
aes.finish()
# Desencriptar CBC
aes.start(AESContext.MODE_CBC_DECRYPT, clave.to_utf8(), iv.to_utf8())
desencriptado = aes.update(encriptado)
aes.finish()
# Comprobar CBC
assert(desencriptado == datos.to_utf8())
Métodos¶
void |
finish ( ) |
get_iv_state ( ) |
|
start ( Mode mode, PoolByteArray key, PoolByteArray iv=PoolByteArray( ) ) |
|
update ( PoolByteArray src ) |
Enumeraciones¶
enum Mode:
MODE_ECB_ENCRYPT = 0 --- Modo encripción AES electronic codebook(ECB).
MODE_ECB_DECRYPT = 1 --- Modo desencripción AES electronic codebook(ECB).
MODE_CBC_ENCRYPT = 2 --- Modo encripción AES cipher blocker chaining (CBC).
MODE_CBC_DECRYPT = 3 --- Modo desencripción AES cipher blocker chaining (CBC).
MODE_MAX = 4 --- Valor máximo para el modo enum.
Descripciones de Métodos¶
void finish ( )
Cerrar este contexto AES para que pueda ser iniciado de nuevo. Ver start.
PoolByteArray get_iv_state ( )
Get the current IV state for this context (IV gets updated when calling update). You normally don't need this function.
Note: This function only makes sense when the context is started with MODE_CBC_ENCRYPT or MODE_CBC_DECRYPT.
Error start ( Mode mode, PoolByteArray key, PoolByteArray iv=PoolByteArray( ) )
Inicia el contexto AES en el mode
. Siempre debe proporcionarse un key
de 16 o 32 bytes, mientras que un iv
(vector de inicialización) de exactamente 16 bytes, sólo se necesitará cuando el mode
es o bien MODE_CBC_ENCRYPT o bien MODE_CBC_DECRYPT.
PoolByteArray update ( PoolByteArray src )
Run the desired operation for this AES context. Will return a PoolByteArray containing the result of encrypting (or decrypting) the given src
. See start for mode of operation.
Note: The size of src
must be a multiple of 16. Apply some padding if needed.