Difference between revisions of "Cryptography.aesEncrypt"

From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2016.04<br/> === Description === Encrypt a string with AES 128 cipher, either in ECB mode or CBC mode <source lang="lua"> (string), =...")
 
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
 
 
'''Available since:''' Gideros 2016.04<br/>
 
'''Available since:''' Gideros 2016.04<br/>
 +
'''Class:''' [[Cryptography]]<br/>
 +
 
=== Description ===
 
=== Description ===
Encrypt a string with AES 128 cipher, either in ECB mode or CBC mode
+
Encrypts a string with AES cipher, either in ECB mode or CBC mode.
<source lang="lua">
+
<syntaxhighlight lang="lua">
(string), = Cryptography.aesEncrypt(plaintextkeyivpaddingType,)
+
(string) = Cryptography.aesEncrypt(plaintext,key,iv,paddingType)
</source>
+
</syntaxhighlight>
'''plaintext:''' (string) The message to be encrypted ''''''<br/>
+
 
'''key:''' (string) encryption key as a 16 byte string ''''''<br/>
+
=== Parameters ===
'''iv:''' (string) a 16 byte IV to be used for CBC mode. If not provided ECB mode is used. '''optional'''<br/>
+
'''plaintext''': (string) the message to be encrypted<br/>
'''paddingType:''' (number) Type of padding to be used. Currently defined values are:</br>
+
'''key''': (string) encryption key as a 16,24 or 32 byte string<br/>
 +
'''iv''': (string) a 16 byte IV to be used for CBC mode. If not provided ECB mode is used '''optional'''<br/>
 +
'''paddingType''': (number) type of padding to be used. Currently defined values are:</br>
 
<ul>
 
<ul>
<li>0: 0 padding </li>
+
<li>0: 0 padding '''optional'''</li>
<li>1: PKCS7 padding</li>
+
<li>1: PKCS7 padding '''optional'''</li>
</ul> '''optional'''<br/>
+
</ul>
 +
 
 +
=== Return values ===
 
'''Returns''' (string) ciphered message<br/>
 
'''Returns''' (string) ciphered message<br/>
 +
 +
{{Cryptography}}

Latest revision as of 14:26, 13 July 2023

Available since: Gideros 2016.04
Class: Cryptography

Description

Encrypts a string with AES cipher, either in ECB mode or CBC mode.

(string) = Cryptography.aesEncrypt(plaintext,key,iv,paddingType)

Parameters

plaintext: (string) the message to be encrypted
key: (string) encryption key as a 16,24 or 32 byte string
iv: (string) a 16 byte IV to be used for CBC mode. If not provided ECB mode is used optional
paddingType: (number) type of padding to be used. Currently defined values are:

  • 0: 0 padding optional
  • 1: PKCS7 padding optional

Return values

Returns (string) ciphered message