Plugin.XamarinFileEncryptorDecryptor
1.0.2
dotnet add package Plugin.XamarinFileEncryptorDecryptor --version 1.0.2
NuGet\Install-Package Plugin.XamarinFileEncryptorDecryptor -Version 1.0.2
<PackageReference Include="Plugin.XamarinFileEncryptorDecryptor" Version="1.0.2" />
paket add Plugin.XamarinFileEncryptorDecryptor --version 1.0.2
#r "nuget: Plugin.XamarinFileEncryptorDecryptor, 1.0.2"
// Install Plugin.XamarinFileEncryptorDecryptor as a Cake Addin
#addin nuget:?package=Plugin.XamarinFileEncryptorDecryptor&version=1.0.2
// Install Plugin.XamarinFileEncryptorDecryptor as a Cake Tool
#tool nuget:?package=Plugin.XamarinFileEncryptorDecryptor&version=1.0.2
Encryptor and Decryptor for Xamarin Using AES
This plugin is to ease developer to implement encryption and decryption in xamarin
Note: All of your projects under a solution must be using Xamarin Forms 3.3.0.912540 or later All projects must be using the same version of Xamarin Forms if not, there will be token error
After installing the plugin into your project from nuget: https://www.nuget.org/packages/Plugin.XamarinFileEncryptorDecryptor/1.0.0#
Note: Password used for decryption must be the same as decryption. Decrypting a decrypted file or encrypting an encrypted file will cause error.
Check out the sample project on how to use the plugin here: https://github.com/magiciangambit/XamarinEncryptorDecryptor
- Gain some infos on getting or creating the path for encrypting or decrypting files You can get some info on this from the sample code, below are some examples:
//For using application directory - no direct access to user
localPath = XamEncDec.GetLocalPath();
//For using roaming directory - not all platform support this
roamingPath = XamEncDec.GetRoamingPath();
//For using external storage path in Android
androidSDPath = "";
if (Device.RuntimePlatform == Device.Android)
androidSDPath = CrossXamarinFileEncryptorDecryptor.Current.GetAndroidExternalStoragePath();
//For using shared document path - commonly for iOS
documentPath = XamEncDec.GetDocumentsPath();
//For using library path in iOS
libraryPath = "";
if (Device.RuntimePlatform == Device.iOS)
libraryPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "..", "Library");
//Other paths that you can use, theres more if you google
localAppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
commonAppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
commonDocPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments);
- Use methods below for encryption and decryption:
public async void EncryptResourceFileToBase64String(Assembly assembly, string resourceName, string password)
{
//eg. encrypt resource file and generate encrypted Base64 string
//XamEncDec.EncryptResourceFileAsBase64String(<Assembly object>,
//<Resource filename>, <password>);
var encryptedString = await XamEncDec.EncryptResourceFileAsBase64String(assembly, "TestFileEncryptDecryptXamarin.Files.MARBLES.JPG", "myPassword");
}
public async void EncryptResourceFileToNewFile()
{
//eg. encrypt resource file and generate a new encrypted file
//XamEncDec.EncryptResourceFileAsNewFile(<Assembly object>, <Resource filename>,
//<True=local directory,False=use custom path>,<set string for custom path>,
//<new/existing folder name>,<new filename>, <password>);
var isFileEncrypted = await XamEncDec.EncryptResourceFileAsNewFile(assembly, "TestFileEncryptDecryptXamarin.Files.MARBLES.JPG",true,"","folderName1","MARBLES.JPG", "myPassword");
}
public async void EncryptFileToBase64String()
{
//eg. encrypt a file and generate encrypted base64 string
//XamEncDec.EncryptFileAsBase64String(<true/false to delete source file>,
//<True=local directory,False=use custom path>, <set string for custom path>,
//<new/existing folder name>, <file name to be encrypted>, <password for encryption>);
var encryptedString = await XamEncDec.EncryptFileAsBase64String(false, true, "", "folderName2", "MARBLES.JPG", "myPassword");
}
public async void EncryptFileToNewFile()
{
//eg. encrypt a file and generate new encrypted file
//XamEncDec.EncryptFileAsNewFile(<true/false to delete source file>,
//<True=local directory,False=use custom path>, <set string for custom path>,
//<new/existing folder name>, <file name to be encrypted>, <password for encryption>,
//<new file name for encrypted file>);
bool isFileEncrypted = false;
if (Device.RuntimePlatform == Device.Android)
{
isFileEncrypted = await XamEncDec.EncryptFileAsNewFile(false, false,
CrossXamarinFileEncryptorDecryptor.Current.GetAndroidExternalStoragePath(),
"folderName1", "MARBLES.JPG", "myPassword", "MARBLES_ENCRYPTED.JPG");
}
}
public async void DecryptEncryptedString(string encryptedString)
{
//eg. decrypt encrypted Base64 string
//XamEncDec.DecryptEncryptedStringAsBase64String(<encrypted string>, <password used for encryption>);
var decryptedString = await XamEncDec.DecryptEncryptedStringAsString(encryptedString, "myPassword");
}
public async void DecryptEncryptedStringToNewFile(string encryptedString)
{
//eg. decrypt encrypted string to a new file
//XamEncDec.DecryptEncryptedStringAsNewFile(<True=local directory,False=use custom path>,
//<set string for custom path>, <folder name for output>, <encrypted Base64 string>,
//<new filename for decrypted file>, <password used for encryption>);
var isFileDecrypted = await XamEncDec.DecryptEncryptedStringAsNewFile(false, androidSDPath, "test7", encryptedString, "test1.jpg", "myPassword");
}
public async void DecryptEncryptedFileToNewFile()
{
//eg. decrypt encrypted file to a new file
//XamEncDec.DecryptFileAsNewFile(<True=local directory,False=use custom path>,
//<set string for custom path>, <folder name for output>, <encrypted filename>,
//<password used for encryption>, <new filename for decrypted file>);
var isFileDecrypted = await XamEncDec.DecryptFileAsNewFile(true, "", "folderName1", "MARBLES_ENCRYPTED.JPG", "myPassword", "MARBLES_DECRYPTED.JPG");
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. monoandroid81 is compatible. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap10.0.16299 is compatible. |
Xamarin.iOS | xamarinios was computed. xamarinios10 is compatible. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- PCLStorage (>= 1.0.0)
-
MonoAndroid 8.1
- PCLStorage (>= 1.0.0)
-
UAP 10.0.16299
- PCLStorage (>= 1.0.0)
-
Xamarin.iOS 1.0
- PCLStorage (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
version 1.0