Lua Requires Chilkat v10.1.0+
Lua
Create or Update a Secret from the Content of a StringBuilder
See more Secrets Examples
Create or update a secret from the content of a Chilkat StringBuilder object.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local secrets = chilkat.Secrets.new()
-- On Windows, this is the Windows Credentials Manager
-- On MacOS/iOS, it is the Apple Keychain
secrets.location = "local_manager"
-- Specify the name of the secret.
-- service and username are required.
-- appName and domain are optional.
-- Note: The values are arbitrary and can be anything you want.
local json = chilkat.JsonObject.new()
json:update_string("appName", "Test")
json:update_string("service", "MyService")
json:update_string("domain", "Xyz")
json:update_string("username", "MySecret")
local sb = chilkat.StringBuilder.new()
sb:append("This is the content of the secret.")
-- Create or update the secret.
local success = secrets:update_secret_sb(json, sb)
if not success then
print(secrets.last_error_text)
return
end
print("Success.")