| Components | All | New | MacOS | Windows | Linux | iOS | ||||
| Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old | |
Encryption.PubKeyEncrypt
Encrypts data with a public key.
| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
| Encryption | 16.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
MBS( "Encryption.PubKeyEncrypt"; InputType; InputData; InputEncoding; PKeyRef; OutputType { ; OutputInfo } ) More
Parameters
| Parameter | Description | Example | Flags |
|---|---|---|---|
| InputType | The type of input. Can be Text, Container, Image, Path, PDF, Data, base64 or Hex. |
"base64" | |
| InputData | The actual input data. Text, container or file path. |
$EncryptedData | |
| InputEncoding | The text encoding for text input. Parameter is ignored for other cases. |
"" | |
| PKeyRef | The reference to the public key. | $pkey | |
| OutputType | The output type. Can be Base64, Hex, Text, File, Path. |
"Hex" | |
| OutputInfo | The addition info for output. For text it is the text encoding, for file container the file name and for path the actual native file path. |
"" | Optional |
Result
Returns OK or error.
Description
Encrypts data with a public key.Using RSA-OAEP, OAEP SHA-256 and MGF1 SHA-256 as needed for Ksef.
Examples
Try encryption:
Let ( [
pub = MBS("PKey.ReadFromFile"; "/Users/cs/Desktop/publickey.pem"; 1);
encrypted = MBS("Encryption.PubKeyEncrypt"; "Text"; "Hello World"; "UTF-8"; pub; "Base64");
pubDetails = MBS("PKey.DescriptionPublicKey"; pub);
r = MBS("PKey.Release"; pub)
]; encrypted & ¶ & ¶ & pubDetails )
Example result:
lrwA062pdE+VexKyoQX1DTmMcIudrSAHdi528u4mYmqHD3CISbXBvaT22RUPZ4SNWjTQ8qUhBQF8M9yuQgUdtkNLT0fWwhvsHcrhQ2PionZ6oKzb3yrej7KtcCd40/x1zRfYHzxJE93G22d2MJmtJRJOEBQM4To7vcD3WSZSD2gbJaOgWg/VAReuh4QB9KWmmcy6p1b7mQwVDn+8a0u+EhaD548ypjkOoEntgstW5ldi3cD/hFOJsrCsHPqH1ythMydZWTcLMKiXolcobtLwswfgjA7npjGPOsN6fMNc8PfKqcPoIjKQWF99VAF6ayxVbNVHyQL8pKN0r0Nj4dnekA==
Public-Key: (2048 bit)
Modulus:
00:d3:f0:26:f6:e6:d3:c9:fe:95:8c:94:c1:7a:12:
b4:98:c1:01:9a:02:7b:29:f6:dd:aa:a0:93:14:4f:
5b:bd:fb:5a:f0:81:e4:8b:3e:97:47:c2:01:21:f6:
ae:57:3b:e8:30:fc:44:3c:25:9b:7a:5f:68:5b:18:
20:05:22:e2:4c:cc:95:ec:b9:07:17:f7:91:a7:74:
42:fb:de:7c:00:cd:f8:14:db:d8:4f:76:dd:23:65:
a3:3a:35:c3:b8:96:7c:24:ec:a1:93:b8:d3:b6:fb:
7f:7d:9f:4a:32:4b:55:a5:b8:21:0c:07:8e:ed:69:
5b:c0:1b:f0:85:da:cc:76:77:a2:59:17:99:8a:98:
3a:f9:10:09:18:69:5e:77:58:e9:d2:94:08:22:d0:
9d:a2:e8:78:ac:f1:6c:71:f1:99:5c:97:0f:af:ec:
1e:3c:50:c1:4c:b8:1e:3d:29:47:17:57:1c:1d:72:
98:35:ff:74:72:37:ab:4a:00:8c:7a:b6:75:b6:0c:
47:9f:0b:b6:12:1a:4b:0d:df:6f:24:7b:8e:d4:f4:
b5:05:2d:65:97:16:fc:42:a6:44:be:4e:10:04:54:
98:90:32:e6:ab:2a:63:50:d5:e5:43:d9:d1:bf:94:
f2:50:b8:04:98:db:be:0d:5e:58:b4:ee:78:b2:88:
db:9b
Exponent: 65537 (0x10001)
pub = MBS("PKey.ReadFromFile"; "/Users/cs/Desktop/publickey.pem"; 1);
encrypted = MBS("Encryption.PubKeyEncrypt"; "Text"; "Hello World"; "UTF-8"; pub; "Base64");
pubDetails = MBS("PKey.DescriptionPublicKey"; pub);
r = MBS("PKey.Release"; pub)
]; encrypted & ¶ & ¶ & pubDetails )
Example result:
lrwA062pdE+VexKyoQX1DTmMcIudrSAHdi528u4mYmqHD3CISbXBvaT22RUPZ4SNWjTQ8qUhBQF8M9yuQgUdtkNLT0fWwhvsHcrhQ2PionZ6oKzb3yrej7KtcCd40/x1zRfYHzxJE93G22d2MJmtJRJOEBQM4To7vcD3WSZSD2gbJaOgWg/VAReuh4QB9KWmmcy6p1b7mQwVDn+8a0u+EhaD548ypjkOoEntgstW5ldi3cD/hFOJsrCsHPqH1ythMydZWTcLMKiXolcobtLwswfgjA7npjGPOsN6fMNc8PfKqcPoIjKQWF99VAF6ayxVbNVHyQL8pKN0r0Nj4dnekA==
Public-Key: (2048 bit)
Modulus:
00:d3:f0:26:f6:e6:d3:c9:fe:95:8c:94:c1:7a:12:
b4:98:c1:01:9a:02:7b:29:f6:dd:aa:a0:93:14:4f:
5b:bd:fb:5a:f0:81:e4:8b:3e:97:47:c2:01:21:f6:
ae:57:3b:e8:30:fc:44:3c:25:9b:7a:5f:68:5b:18:
20:05:22:e2:4c:cc:95:ec:b9:07:17:f7:91:a7:74:
42:fb:de:7c:00:cd:f8:14:db:d8:4f:76:dd:23:65:
a3:3a:35:c3:b8:96:7c:24:ec:a1:93:b8:d3:b6:fb:
7f:7d:9f:4a:32:4b:55:a5:b8:21:0c:07:8e:ed:69:
5b:c0:1b:f0:85:da:cc:76:77:a2:59:17:99:8a:98:
3a:f9:10:09:18:69:5e:77:58:e9:d2:94:08:22:d0:
9d:a2:e8:78:ac:f1:6c:71:f1:99:5c:97:0f:af:ec:
1e:3c:50:c1:4c:b8:1e:3d:29:47:17:57:1c:1d:72:
98:35:ff:74:72:37:ab:4a:00:8c:7a:b6:75:b6:0c:
47:9f:0b:b6:12:1a:4b:0d:df:6f:24:7b:8e:d4:f4:
b5:05:2d:65:97:16:fc:42:a6:44:be:4e:10:04:54:
98:90:32:e6:ab:2a:63:50:d5:e5:43:d9:d1:bf:94:
f2:50:b8:04:98:db:be:0d:5e:58:b4:ee:78:b2:88:
db:9b
Exponent: 65537 (0x10001)
See also
Blog Entries
This function checks for a license.
Created 22nd May 2026, last changed 22nd May 2026
MarkDown version: EncryptionPubKeyEncrypt.md