Hi,
Kindly share the code for encrypting the license file forever and before setting license it has to get decrypted and read the content.
Thanks & Regards,
Poornima K
Hi Poornima,
Thanks for your posting and using Aspose.Cells.
You can encrypt your License string with simple XOR operation using some integer KEY and it will give you encrypted license string. You can then save this string in some file. Later on, you can read this encrypted license string and then XOR it with the same integer KEY and it will decrypt your encrypted license string and then you can use this decrypted license string to set your license.
For example, please see the following code. It has a method that encrypts and decrypts any string. The second method test this method with a sample string and prints in debug window. Please check the debug output of this code at below.
C#
static string EncryptDecryptLicense(int key, string input)
{
//Read original file as byte array
char[] originalBytes = input.ToCharArray();
//Create output string
string outputString = string.Empty;
//Loop through all bytes in original array and encode each byte using XOR operation
for (int i = 0; i < originalBytes.Length; i++)
{
outputString += (char)(originalBytes[i] ^ key);
}
return outputString;
}
void RUN()
{
int YOUR_XOR_KEY = 194;
string YOUR_LICENSE_STRING = “This is a simple license text. Use your own license string here.”;
string encryptedLicense = EncryptDecryptLicense(YOUR_XOR_KEY, YOUR_LICENSE_STRING);
//Print your encoded license
Debug.WriteLine("Encrypted License: " + encryptedLicense);
//Now decode your encoded license
string decryptedLicense = EncryptDecryptLicense(YOUR_XOR_KEY, encryptedLicense);
//Print your decoded license
Debug.WriteLine("Decrypted License: " + decryptedLicense);
}
Debug Console Output:
Encrypted License: ª«±â«±â£â±«¯²®§â®«¡§¬±§â¶§º¶ìⱧ⻷°âµ¬â®«¡§¬±§â±¶°«¬¥âª§°§ì
Decrypted License: This is a simple license text. Use your own license string here.
Once, you get your decrypted license string, you can set the license in this way. First, you will convert your decrypted license string into memory stream and then pass it to License.SetLicense() method.
C#
string decryptedLicense = ...
MemoryStream licStrm = new System.IO.MemoryStream(Encoding.UTF8.GetBytes(decryptedLicense));
//Set license
Aspose.Cells.License lic = new Aspose.Cells.License();
lic.SetLicense(licStrm);
Hi,
Hi,
Thanks for your posting and using Aspose.Cells.
If you will encrypt the license, then you can save its content in any file on disk. This way, no one can steal your license because it is encrypted and no use for anyone. Only, you know how to decrypt it back and set the license.
This approach works for any file which you do not want to reveal or get stolen by anyone. For example, in ASP.NET web application, people encrypts web.config file with some encryption algorithm to save it from being stolen by others because it might contain some confidential data.
Thanks for your reply,
Hi,
Thanks for your posting and using Aspose.Cells.
No, you will not place the original file on disk. You will only place encrypted file on disk.
For example, if your file contains “This is my hello string” and you encrypt it once say “xsaskllkamklmasdm”, then you will delete your original file containing “This is my hello string” and only place the encrypted file containing “xsaskllkamklmasdm” on disk.
Now, if someone steals your encrypted file containing “xsaskllkamklmasdm”, then it is of no use to him because he does not understand the encrypted contents.
Only, you know the encrypted contents and you can decrypt “xsaskllkamklmasdm” back to “This is my hello string”.
Many applications stores their confidential information on disk in encrypted form which no one can understand except they themselves.
FYI:
.NET framework APIs provide many advanced encryption algorithm which you can use to encrypt your contents with very strong encryption.
HI Brother,
is there any option for Decrypt .lic File
Please refer to Protecting your License File for information on how to protect your .NET, Java or Android license. To access the page, you need to be logged in and have at least one paid order.
If you have questions about our licenses, read the Licensing FAQ.