Excel kayan aiki ne da ake amfani da shi sosai don tsarawa da nazarin bayanai. Koyaya, wani lokacin bayanan da ke ƙunshe a cikin fayil ɗin Excel na iya zama mai hankali ko sirri, kuma yana da mahimmanci don kare shi daga shiga mara izini. Ta hanyar kare kalmar sirri da rufaffen fayilolin Excel, zaku iya kiyaye bayanan ku kuma ku hana shi fadawa cikin hannun da ba daidai ba. Wannan fasalin yana da mahimmanci musamman ga kasuwanci da ƙungiyoyi waɗanda ke mu’amala da bayanan sirri. A cikin wannan labarin, za mu nuna muku yadda ake kare kalmar sirri da ɓoye fayilolin Excel ta amfani da C# .NET, ta yadda za ku iya kiyaye bayananku da kare sirrin ku.
- API zuwa Kalmar wucewa Kare Fayilolin Excel
- Encrypt Excel File ta amfani da C#
- Ƙara Kalmar wucewa zuwa Excel ta amfani da Umarnin CURL
API zuwa Kalmar wucewa Kare Fayilolin Excel
Aspose.Cells Cloud SDK don NET kayan aiki ne mai ban mamaki wanda ke ba masu haɓaka damar ƙara kariyar kalmar sirri cikin sauƙi zuwa fayilolin Excel. Tare da wannan fasalin, zaku iya kare mahimman bayanai kuma ku hana damar shiga fayilolinku mara izini. Kariyar kalmar sirri yana da mahimmanci ga ‘yan kasuwa da masu amfani da su, waɗanda suka damu sosai game da keɓaɓɓen bayanansu. Wannan API ɗin yana sauƙaƙa don ƙara kariyar kalmar sirri zuwa fayilolin Excel ɗinku, ba tare da buƙatar hadaddun coding ko ƙarin software ba.
Yanzu bincika Aspose.Cells-Cloud a cikin “NuGet Package Manager” kuma danna maɓallin “Ƙara Kunshin”. Na biyu, idan baku da asusu akan Cloud Dashboard, da fatan za a ƙirƙiri asusun kyauta ta amfani da ingantaccen adireshin imel kuma sami keɓaɓɓen takaddun shaidarku.
Encrypt Excel File ta amfani da C#
Da fatan za a gwada amfani da snippet code mai zuwa don ƙara kalmar sirri zuwa littafin Aiki na Excel.
Mun yi amfani da XOR azaman nau’in ɓoyewa kuma ana iya sanya ɗayan dabi’u masu zuwa zuwa kayan EncryptionType
- XOR
- Mai jituwa
- EnhancedCryptographicProviderV1
- StrongCryptographic Mai ba da kyauta
// Don cikakkun misalai da fayilolin bayanai, da fatan za a je zuwa
https://github.com/aspose-cells-cloud/aspose-cells-cloud-dotnet/
// Samu bayanan abokin ciniki daga https://dashboard.aspose.cloud/
string clientSecret = "4d84d5f6584160cbd91dba1fe145db14";
string clientID = "bb959721-5780-4be6-be35-ff5c3a6aa4a2";
// ƙirƙiri misalin CellsApi yayin wuce ClientID da ClientSecret
CellsApi cellsInstance = new CellsApi(clientID, clientSecret);
// Littafin aikin farko na Excle akan tuƙi
string input_Excel = "myDocument.xlsx";
try
{
// karanta fayil ɗin Excel a cikin misalin Fayil
var file = System.IO.File.OpenRead(input_Excel);
// loda Excel zuwa ajiyar girgije
cellsInstance.UploadFile(input_Excel, File.OpenRead(input_Excel));
// Ƙirƙiri abin neman ɓoyewa kuma ayyana nau'in ɓoyewa da cikakkun bayanan kalmar sirri
WorkbookEncryptionRequest encryption = new WorkbookEncryptionRequest();
encryption.Password = "123456";
encryption.KeyLength = 128;
encryption.EncryptionType = "XOR";
// fara aikin juyawa
var response = cellsInstance.CellsWorkbookPostEncryptDocument(input_Excel, encryption, null);
// buga saƙon nasara idan haɗin kai ya yi nasara
if (response != null && response.Equals("OK"))
{
Console.WriteLine("Excel is successfully Encrypted !");
Console.ReadKey();
}
}
catch (Exception ex)
{
Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}
Yanzu bari mu haɓaka fahimtarmu game da snippet code:
CellsApi cellsInstance = new CellsApi(clientID, clientSecret);
Ƙirƙiri wani abu na CellsApi yayin ƙaddamar da bayanan abokin ciniki azaman muhawara.
var file = System.IO.File.OpenRead(input_ODS);
Karanta abun ciki na shigar da Excel daga injin tsarin gida.
cellsInstance.UploadFile(input_Excel, File.OpenRead(input_Excel));
Loda shigarwar Excel zuwa ma’ajiyar gajimare.
WorkbookEncryptionRequest encryption = new WorkbookEncryptionRequest();
encryption.Password = "123456";
encryption.KeyLength = 128;
encryption.EncryptionType = "XOR";
Ƙirƙiri buƙatun ɓoyayyen littafin Aiki inda muka ayyana XOR azaman nau’in ɓoyewa.
var response = cellsInstance.CellsWorkbookPostEncryptDocument(input_Excel, encryption, null);
A ƙarshe, kira wannan hanyar don kalmar sirri ta kare fayil ɗin Excel. Za a adana fayil ɗin da aka rufaffen a cikin ma’ajin gajimare.
Za a iya sauke samfurin fayil ɗin Excel da aka yi amfani da shi a cikin misalin da ke sama daga myDocument.xlsx.
Ƙara Kalmar wucewa zuwa Excel ta amfani da Umarnin CURL
cURL kayan aiki ne na layin umarni wanda ke ba ka damar canja wurin bayanai zuwa kuma daga sabar ta amfani da ka’idoji daban-daban, gami da HTTP, HTTPS, FTP, da ƙari. Umarnin CURL kuma na iya zama da amfani don rubutun rubutu da dalilai na sarrafa kansa. Wannan na iya zama da amfani musamman idan kuna da ɗimbin fayilolin Excel waɗanda ke buƙatar ɓoyewa, ko kuma idan kuna buƙatar yin wannan aikin akai-akai. Saboda haka, maimakon yin waɗannan ayyuka da hannu ta amfani da mai binciken gidan yanar gizo ko mai amfani da hoto mai hoto, zaku iya amfani da umarnin cURL don yin hulɗa tare da Aspose.Cells Cloud API kai tsaye daga layin umarni.
Don farawa, kuna buƙatar shigar da cURL akan tsarin ku sannan ku samar da damar shigaToken dangane da bayanan abokin ciniki:
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Yi amfani da umarni mai zuwa don loda shigarwar Excel zuwa ma’ajiyar gajimare:
curl -v "https://api.aspose.cloud/v3.0/cells/storage/file/{filePath}" \
-X PUT \
-F file=@{localFilePath} \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer {accessToken}"
Sauya
{filePath}
tare da hanyar da kake son adana fayil ɗin a cikin ma’ajiyar gajimare, `{localFilePath}’ tare da hanyar fayil ɗin Excel akan tsarin gida, da ‘‘accessToken}’ tare da damar Aspose Cloud. alama.
A ƙarshe, aiwatar da umarni mai zuwa don kare kalmar sirri ta fayil ɗin Excel:
curl -v "https://api.aspose.cloud/v3.0/cells/{excelName}]/encryption" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: application/json" \
-d "{ \"EncryptionType\": \"XOR\", \"KeyLength\": 128, \"Password\": \"123456\"}"
Sauya
{excelName}
da sunan fayil ɗin Excel da kuka ɗora zuwa ma’ajiyar gajimare, da ‘‘accessToken}’ tare da alamar shiga da aka samar a sama. Bayan aiwatarwa, za a adana sakamakon Excel a cikin ma’aunin girgije iri ɗaya.
Karshen Magana
Mun koyi cewa Aspose.Cells Cloud SDK don NET yana ba da hanya mai sauƙi kuma amintacce don kare kalmar sirri da ɓoye fayilolin Excel ta amfani da umarnin cURL da hanyoyin API. Gabaɗaya, Aspose.Cells Cloud SDK don NET kayan aiki ne mai kyau ga masu haɓakawa waɗanda ke buƙatar aiwatar da matakan tsaro don fayilolin Excel. Ta amfani da wannan API, masu haɓakawa za su iya tabbatar da cewa bayanan sirri da aka adana a cikin fayilolin Excel an kiyaye su daga shiga mara izini, kuma suna bin ka’idodi. A ƙarshe, API ɗin ya tabbatar da zama kayan aiki mai amfani don cika buƙatar kariyar kalmar sirri da ɓoye fayilolin Excel.
Hanyoyin haɗi masu amfani
Abubuwan da aka Shawarar
Da fatan za a ziyarci hanyoyin haɗin yanar gizon don ƙarin koyo game da: