Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4   7.5    Statistic  

RSA.PublicEncrypt

Encrypts data using public key.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
Encryption 6.2 Yes Yes Yes Yes Yes

MBS( "RSA.PublicEncrypt"; InputType; InputData; InputEncoding; KeyType; KeyData; KeyEncoding; OutputType { ; OutputInfo; PasswordType; PasswordData; PasswordEncoding; Padding } )

Parameters

Parameter Description Example value
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 Optional
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.
""
PasswordType Optional
The type of input for the password of the private key.
Can be Text, Container, Image, Path, PDF, Data, base64 or Hex.
"Text"
PasswordData Optional
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"
PasswordEncoding Optional
The text encoding for text input.
Parameter is ignored for other cases.
"UTF-8"
Padding Optional
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

Result

Returns encrypted data or error.

Description

Encrypts data using public 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.PrivateDecrypt.
You can create a new private key using RSA.GeneratePrivateKey function. The RSA.GetPublicKey function extracts the public key from a private key.

Examples

Encrypt with public key:

Set Variable [$r; Value:MBS( "RSA.PublicEncrypt"; "Text"; RSA Public Private Encryption::InputText; "UTF-8"; "Text"; RSA Public Private Encryption::PublicKey; "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


RSA.PublicDecrypt   -   RSA.Sign

Feedback: Report problem or ask question.




Links
MBS Xojo Plugins