Exemplo n.º 1
0
        //  Methods
        // ////////////////////////////////////////////////////////////////////

        // - Load
        internal static SignedLicense Deserialize(string content)
        {
            if (string.IsNullOrEmpty(content))
            {
                throw new ArgumentException($"'{nameof(content)}' must not null or empty.");
            }
            var firstLine   = content.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).First();
            var isEncrypted = !Licensing.HardwareIdentifier.IsCheckSumValid(firstLine);

            if (isEncrypted)
            {
                content = content.Unwrap();
                content = SignedLicenseEncryption.Dencrypt(content);
            }
            var lines = (content ?? "").Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            if (lines.Length < 4)
            {
                ThrowInvalidFormatException();
            }

            return(ReadLicenseFile(lines));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Serializes the license as encrypted base64 encoded text.
 /// </summary>
 /// <returns></returns>
 public string Serialize()
 {
     return(SignedLicenseEncryption.Encrypt(SerializeAsPlainText()));
 }