Encryption.EncryptAES
---------------------

Encrypts data with with AES engine in CBC mode.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Encryption](component_Encryption.md) | [2.7](newinversion27.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

### Deprecated

This function was [deprecated](deprecated.md). Use [Encryption.Cipher](EncryptionCipher.md) instead.

MBS( "Encryption.EncryptAES"; Key; Text { ; iv } ) 

**MBS**( **"Encryption.EncryptAES";** /\* Encrypts data with with AES engine in CBC mode. \*/  
**$Key**; /\* The key you want to use.e.g. "Hello" \*/   
**$Text**; /\* The text to encrypt.e.g. "Hello World" \*/   
**$iv**) /\* Optional; The initial vector as a text with up to 16 bytes length.e.g. "1234567890ABCDEF" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Key | The key you want to use. | "Hello" |  |
| Text | The text to encrypt. | "Hello World" |  |
| iv | The initial vector as a text with up to 16 bytes length. | "1234567890ABCDEF" | Optional |

### Result

Returns encrypted text encoded as hex.

### Description

Encrypts data with with AES engine in CBC mode.  
This function uses UTF-8 for key, text and iv parameters.  
Keys shorter than 128 bit, 192 bit or 256 bit length are padded with null bytes to right size. This means that only the first 32 characters are used at most.  
  
Deprecated. Please move to [Encryption.Cipher](EncryptionCipher.md) for new projects.  
### Examples

Simply encrypt a text:

 MBS ( "Encryption.EncryptAES"; $key ; $text )  
Trying to reproduce Encryption.EncryptAES with [Encryption.Cipher](EncryptionCipher.md):

 # So, let's try a test case:   
  
Set Variable \[ $r1 ; Value: MBS ( "Encryption.EncryptAES"; "Hello World"; "Hello World")\]  
\# 514532926253C04A15302CF85BD7C816   
  
\# And sicken AES adds zeros to fill blocks, we have to use hex mode here:   
Set Variable \[ $r2 ; Value: MBS ( "[Encryption.Cipher](EncryptionCipher.md)"; "encrypt"; "AES-128-CBC";   
"Hex"; HexEncode("Hello World") ; "";   
"Hex"; HexEncode("Hello World") &amp; "0000000000"; "";   
"Hex"; "";   
""; ""; ""; 0 ) \]  
\# Gives   
\# 514532926253C04A15302CF85BD7C8168E6AE36F6FB574F32FEA6932A5E0595F   
\#   
\# Which looks like it uses two blocks instead of one above.   
### See also

- [Encryption.Cipher](EncryptionCipher.md)
- [Encryption.DecryptAES](EncryptionDecryptAES.md)
- [Encryption.DecryptBlowfish](EncryptionDecryptBlowfish.md)

### Release notes

- **Version 8.5**
    - Fixed problem with [Encryption.EncryptAES](http://www.mbsplugins.eu/EncryptionEncryptAES.shtml) function if byte size is not a multiply of 16.

### Example Databases

- [Encryption and Hash/AES](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Encryption%20and%20Hash/AES.shtml#1ScriptAnchor_)

### Blog Entries

- [MBS Filemaker Plugin, version 2.7fc](https://www.mbsplugins.de/archive/2012-05-08/MBS_Filemaker_Plugin_version_2/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin 2.7 Release notes](https://www.mbsplugins.de/archive/2012-05-08/MBS_Filemaker_Plugin_27_Releas/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 2.7pr4](https://www.mbsplugins.de/archive/2012-04-11/MBS_Filemaker_Plugin_version_2/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 25th February 2026

  
[Encryption.DigestNames](EncryptionDigestNames.md) - [Encryption.EncryptBlowfish](EncryptionEncryptBlowfish.md)

[HTML Version](EncryptionEncryptAES.shtml)