Skip to contents

Encrypted data administration; functions for setting up, adding users, etc.


data_admin_init(path_data, path_user = NULL, quiet = FALSE)

  path_data = NULL,
  hash = NULL,
  path_user = NULL,
  yes = FALSE,
  quiet = FALSE

data_admin_list_requests(path_data = NULL)

data_admin_list_keys(path_data = NULL)



Path to the data set. We will store a bunch of things in a hidden directory within this path. By default in most functions we will search down the tree until we find the .cyphr directory


Path to the directory with your ssh key. Usually this can be omitted.


Suppress printing of informative messages.


A vector of hashes to add. If provided, each hash can be the binary or string representation of the hash to add. Or omit to add each request.


Skip the confirmation prompt? If any request is declined then the function will throw an error on exit.


data_admin_init initialises the system; it will create a data key if it does not exist and authorise you. If it already exists and you do not have access it will throw an error.

data_admin_authorise authorises a key by creating a key to the data that the user can use in conjunction with their personal key.

data_admin_list_requests lists current requests.

data_admin_list_keys lists known keys that can access the data. Note that this is not secure; keys not listed here may still be able to access the data (if a key was authorised and moved elsewhere for example). Conversely, if the user has deleted or changed their key they will not be able to access the data despite the key being listed here.

See also

data_request_access() for requesting access to the data, and and data_key for using the data itself. But for a much more thorough overview, see the vignette (vignette("data", package = "cyphr")).


# The workflow here does not really lend itself to an example,
# please see the vignette instead.

# First we need a set of user ssh keys.  In a non example
# environment your personal ssh keys will probably work well, but
# hopefully they are password protected so cannot be used in
# examples.  The password = FALSE argument is only for testing,
# and should not be used for data that you care about.
path_ssh_key <- tempfile()
cyphr::ssh_keygen(path_ssh_key, password = FALSE)

# Initialise the data directory, using this key path.  Ordinarily
# the path_user argument would not be needed because we would be
# using your user ssh keys:
path_data <- tempfile()
dir.create(path_data, FALSE, TRUE)
cyphr::data_admin_init(path_data, path_user = path_ssh_key)
#> Generating data key
#> Authorising ourselves
#> Adding key 57:fe:51:5d:90:6d:15:71:73:13:87:bd:47:0e:7f:85:27:cb:79:61:b9:6b:2d:d8:e7:77:54:42:e6:95:c8:68
#>   user: root
#>   host: ac5bacf9b4a6
#>   date: 2024-06-12 05:16:56.945627
#> Verifying

# Now you can get the data key
key <- cyphr::data_key(path_data, path_user = path_ssh_key)

# And encrypt things with it
cyphr::encrypt_string("hello", key)
#>  [1] cd 17 16 b7 e3 b2 cf c9 ad 73 2f bb d8 42 75 27 88 11 a9 5a 6f f0 0d ed 36
#> [26] ac 3d 89 6b 93 d3 78 a4 02 e0 41 f0 19 c7 5b ee 74 8f 66 a5

# See the vignette for more details.  This is not the best medium
# to explore this.

# Cleanup
unlink(path_ssh_key, recursive = TRUE)
unlink(path_data, recursive = TRUE)