getSecret - Retrieve secret value from MATLAB vault - MATLAB (original) (raw)

Main Content

Retrieve secret value from MATLAB vault

Since R2024a

Syntax

Description

getSecret([secretname](#mw%5Fb9d61e32-88aa-4013-b5da-4ea101000d41)) retrieves the secret value with the specified name from your MATLAB® vault. Your MATLAB vault is accessible only from the exact combination of your operating system account and local machine.

example

[v](#mw%5Fa68e89cd-1cfe-4d6b-bb23-3139109fde2e) = getSecret([secretname](#mw%5Fb9d61e32-88aa-4013-b5da-4ea101000d41)) assigns the secret value to a variable. Displaying the variable value makes the secret visible.

example

Examples

collapse all

Retrieve a secret value from your vault.

getSecret("ExamplePassword")

Retrieve a secret value from your vault and assign it to a variable. Note that assigning a secret value to a variable makes the value visible.

SFTPpassword = getSecret("ExamplePassword")

SFTPpassword =

"pass_word123"

Create a secret to store your SFTP server password by initiating the Secret Prompt dialog box with the name of your secret.

setSecret("SFTPpassword")

Use the dialog box to set your secret value and add the secret to your MATLAB vault. Toggle the eye icon in the text box to hide or show the characters in your value.

Secret Prompt dialog box, with a text box to enter the SFTPpassword value

To provide the SFTP server password, use the secret from your vault containing the password value.

s = sftp("sftp.example.net","adam",Password=getSecret("SFTPpassword"));

Input Arguments

collapse all

Unique case-sensitive text identifier for the secret, specified as a string scalar or character vector. You can use a secret to hold sensitive information, such as passwords, certificates, credentials, OAuth tokens, and other configuration data for:

Output Arguments

collapse all

Secret value, returned as a string scalar. Assigning a secret value to a variable makes the value visible.

More About

collapse all

Your secrets are stored in your MATLAB vault, which is accessible only from the exact combination of your operating system account and local machine. Your vault and secrets, which do not leave your local machine, persist across MATLAB sessions. Each secret consists of a name, value, and optional metadata.

To set a secret, use setSecret.

For increased security when you use MATLAB Online™, enable two-step verification for your MathWorks® Account.

Extended Capabilities

Version History

Introduced in R2024a

expand all

The secretname argument now supports the forward slash character (/).

This function supports thread-based environments.