Xecrets.Sdk.XfExtensions.md
May 26, 2026 · View on GitHub
Xecrets.Sdk
Xecrets.Sdk
XfExtensions Class
Useful extension methods for file names
public static class XfExtensions
Inheritance System.Object → XfExtensions
Methods
XfExtensions.AddEncryptedExtension(this string) Method
Add the extension for an encrypted file
public static string AddEncryptedExtension(this string file);
Parameters
file System.String
A file name, presumably without extension
Returns
System.String
The file parameter with the extension for encrypted files concatented.
XfExtensions.AddKeyPairFullName(this XfCredentials, string) Method
Add a key pair residing in a file to a credentials collection.
public static void AddKeyPairFullName(this Xecrets.Sdk.Models.XfCredentials xfCredentials, string keyPairFullName);
Parameters
xfCredentials XfCredentials
The XfCredentials to use.
keyPairFullName System.String
The key pair full path and name.
XfExtensions.AddPassword(this XfCredentials, string) Method
Add a password to a collection of credentials.
public static void AddPassword(this Xecrets.Sdk.Models.XfCredentials xfCredentials, string password);
Parameters
xfCredentials XfCredentials
The XfCredentials to use.
password System.String
The password to add to the collection.
XfExtensions.DecryptFileAsync(this IXfApi, XfCredentials, string) Method
Attempt to decrypt a file
public static System.Threading.Tasks.Task<byte[]?> DecryptFileAsync(this Xecrets.Sdk.Abstractions.IXfApi xfApi, Xecrets.Sdk.Models.XfCredentials xfCredentials, string fileFullName);
Parameters
xfApi IXfApi
The IXfApi instance to use.
xfCredentials XfCredentials
The XfCredentials to use.
fileFullName System.String
The destination full path and name.
Returns
System.Threading.Tasks.Task<System.Byte[]>
XfExtensions.Encrypted(this IEnumerable) Method
Select the files that appear to be encrypted, according to their extension.
public static string[] Encrypted(this System.Collections.Generic.IEnumerable<string> files);
Parameters
files System.Collections.Generic.IEnumerable<System.String>
File names to filter
Returns
System.String[]
An array of the files that match the pattern for encrypted files.
XfExtensions.EncryptFileAsync(this IXfApi, XfCredentials, string, byte[], string) Method
Encrypt an in-memory blob as a file
public static System.Threading.Tasks.Task EncryptFileAsync(this Xecrets.Sdk.Abstractions.IXfApi xfApi, Xecrets.Sdk.Models.XfCredentials xfCredentials, string originalFileName, byte[] clearBytes, string fileFullName);
Parameters
xfApi IXfApi
The IXfApi instance to use.
xfCredentials XfCredentials
The XfCredentials to use.
originalFileName System.String
The original file name to embed in the encrypted file.
clearBytes System.Byte[]
The data blob to encrypt.
fileFullName System.String
The destination full path and name.
Returns
XfExtensions.IsEncrypted(this string) Method
A predicate determining of the name of a file has the suggested encrypted extension, i.e. .axx
public static bool IsEncrypted(this string file);
Parameters
file System.String
A possibly full path and name of a file.
Returns
System.Boolean
true if the name ends with the encrypted extension.
XfExtensions.NotEncrypted(this IEnumerable) Method
Select the files that appear not to be encrypted, according to their extension.
public static System.Collections.Generic.IEnumerable<string> NotEncrypted(this System.Collections.Generic.IEnumerable<string> files);
Parameters
files System.Collections.Generic.IEnumerable<System.String>
File names to filter
Returns
System.Collections.Generic.IEnumerable<System.String>
An enumeration of the files that do not match the pattern for encrypted files.
XfExtensions.ToEncryptedName(this string, string) Method
Build an encrypted file name from the original file name, i.e. according to the pattern: filename.ext => filename-ext.axx
public static string ToEncryptedName(this string fullName, string destinationFileFullFolder);
Parameters
fullName System.String
The full path and name of a plain text file, possibly with an extension.
destinationFileFullFolder System.String
The full path to an optional destination folder. Set to empty string if same as source.
Returns
System.String
The suggested name for it when encrypted.