Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

RSA.PrivateEncrypt

Encrypts data using private key.

Component Version macOS Windows Linux Server iOS SDK
Encryption 6.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "RSA.PrivateEncrypt"; InputType; InputData; InputEncoding; KeyType; KeyData; KeyEncoding; OutputType { ; OutputInfo; PasswordType; PasswordData; PasswordEncoding; Padding } )   More

Parameters

Parameter Description Example Flags
InputType The type of input data.
Can be Text, Container, Image, Path, PDF, Data, base64 or Hex.
"Text"
InputData The actual input data.
Text, container or file path.
"Hello World"
InputEncoding The text encoding for text input.
Parameter is ignored for other cases.
"UTF-8"
KeyType The type of input for private key.
Can be Text, Container, Image, Path, PDF, Data, base64 or Hex.
"Path"
KeyData The actual input data for the key.
Text, container or file path. Must not be longer than the maximum key length of the given algorithm. If key is too short, we pad it with zero bytes.
"/Users/cs/desktop/test.pem"
KeyEncoding The text encoding for text input for the key.
Parameter is ignored for other cases.
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
PasswordType The type of input for the password of the private key.
Can be Text, Container, Image, Path, PDF, Data, base64 or Hex.
"Text" Optional
PasswordData The actual input data for the password of the private key.
Text, container or file path. Must not be longer than the maximum key length of the given algorithm. If key is too short, we pad it with zero bytes.
"Hello World" Optional
PasswordEncoding The text encoding for text input.
Parameter is ignored for other cases.
"UTF-8" Optional
Padding Which padding to use.
1: PKCS #1 v1.5 padding. This currently is the most widely used mode.
2: PKCS #1 v1.5 padding with an SSL-specific modification that denotes that the server is SSL3 capable.
3: Raw RSA encryption. This mode should only be used to implement cryptographically sound padding modes in the application code. Encrypting user data directly with RSA is insecure.
4: EME-OAEP as defined in PKCS #1 v2.0 with SHA-1, MGF1 and an empty encoding parameter. This mode is recommended for all new applications.
5: X931 padding.
Default if not specified is 1.
1 Optional

Result

Returns encrypted data or error.

Description

Encrypts data using private key.
Using RSA keys with any key size.
Password is optional for decrypting encrypted keys.

You can encrypt the data here and later decrypt with RSA.PublicDecrypt.
You can create a new private key using RSA.GeneratePrivateKey function.

Examples

Encrypt with private key:

Set Variable [$r; Value:MBS( "RSA.PrivateEncrypt"; "Text"; RSA Public Private Encryption::InputText; "UTF-8"; "Text"; RSA Public Private Encryption::PrivateKey; "UTF-8"; "Base64")]
If [MBS("IsError")]
    Show Custom Dialog ["Error"; $r]
Else
    Set Field [RSA Public Private Encryption::EncryptedText; $r]
End If

See also

Example Databases

Blog Entries

This function is free to use.

Created 21st April 2016, last changed 30th May 2016


RSA.PrivateDecrypt - RSA.PublicDecrypt