/// <summary> /// Gets an instance of <see cref="IEncryptor"/> for the provided key identifier. /// </summary> /// <param name="keyIdentifier"> /// An implementation-specific object used to identify the key for this /// encryption operation. /// </param> /// <returns>An object that can be used for encryption operations.</returns> public IEncryptor GetEncryptor(object keyIdentifier) { ICredential credential; if (!_credentialRepository.TryGet(keyIdentifier, out credential)) { throw new KeyNotFoundException($"Unable to locate credential using keyIdentifier: {keyIdentifier}"); } return(new SymmetricEncryptor(credential, _encoding)); }