private string CreateRegistrationKey(byte[] licenceBytes) { string regKeyData = GeneralConverters.ByteArrayToBase64(licenceBytes); regKeyData = SerialNumbersSettings.ProtectedApplications.SaltData.GeneralToolkit + regKeyData + SerialNumbersSettings.ProtectedApplications.SaltData.GeneralToolkit + _app; byte[] buffer = null; EncryptionManager.EncodeString(ref buffer, regKeyData, "064lMPnLyjI6sqfXm5KhSE4R0FDU0AchClDyxpAWKkJgFyih59IkhX598sveO7vdbuEKgbEQjDRcLtx0FbcJtASEqHZE8bLX2CIq2LwYZC4OWZGWzx7dv0dxp1h6dcck"); return(ConvertToBase32SerialNumber(buffer)); }
private string CreateRegistrationKey(byte[] licenseBytes) { string regKeyData = GeneralConverters.ByteArrayToBase64(licenseBytes); regKeyData = LicenseGeneratorStaticData.SaltData.GeneralToolkit + regKeyData + LicenseGeneratorStaticData.SaltData.GeneralToolkit + this._app; byte[] buffer = new byte[0]; EncryptionManager.EncodeString(ref buffer, regKeyData, regKeyData); return(this.ConvertToBase32SerialNumber(buffer)); }
public bool Decode(byte[] data, string password) { var msEncoded = new MemoryStream(data); byte[] buffer = new byte[4]; msEncoded.Read(buffer, 0, 4); int encodedBytes = BitConverter.ToInt32(buffer, 0); buffer = new byte[encodedBytes]; msEncoded.Read(buffer, 0, buffer.Length); byte[] decodedBytes = EncryptionManager.DecryptData(buffer, password); msEncoded.Read(buffer, 0, 4); int hashByteLength = BitConverter.ToInt32(buffer, 0); if (hashByteLength > 512) { return(false); } byte[] hashBytesFromData = new byte[hashByteLength]; msEncoded.Read(hashBytesFromData, 0, hashBytesFromData.Length); byte[] hashBytesFromDecodedDataBytes = SHA512.Create().ComputeHash(decodedBytes, 0, decodedBytes.Length); bool hashCompareResult = GeneralConverters.ByteArrayToBase64(hashBytesFromData) == GeneralConverters.ByteArrayToBase64(hashBytesFromDecodedDataBytes); if (!hashCompareResult) { return(false); } var msDecoded = new MemoryStream(decodedBytes); buffer = new byte[4]; msDecoded.Read(buffer, 0, buffer.Length); int leftPaddingLength = BitConverter.ToInt32(buffer, 0); msDecoded.Read(buffer, 0, buffer.Length); int rightPaddingLength = BitConverter.ToInt32(buffer, 0); msDecoded.Read(buffer, 0, buffer.Length); int totalLength = BitConverter.ToInt32(buffer, 0); byte[] decodedDataBlock = new byte[totalLength]; msDecoded.Read(decodedDataBlock, 0, decodedDataBlock.Length); byte[] sharedSecretBytes = new byte[totalLength - leftPaddingLength - rightPaddingLength]; Buffer.BlockCopy(decodedDataBlock, leftPaddingLength, sharedSecretBytes, 0, sharedSecretBytes.Length); SharedSecret = GeneralConverters.GetStringFromByteArray(sharedSecretBytes); return(true); }