Expand description
Package Family Name is a Rust crate for calculating MSIX Package Family Name values.
Every MSIX application has a package family name value, which looks a bit like
AppName_zj75k085cmj1a. This value can easily be found by running Get-AppxPackage <name> in
PowerShell for an installed MSIX package and scrolling to PackageFullName.
However, we can work out a package family name value without needing to install the package at all. That’s where this library comes into play.
§Usage
Add this to your Cargo.toml:
[dependencies]
package-family-name = "2"let package_family_name = PackageFamilyName::new(
"Microsoft.PowerShell",
"CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
);
assert_eq!(package_family_name.to_string(), "Microsoft.PowerShell_8wekyb3d8bbwe");§How a package family name is calculated
In short, a package family name is made up of two parts:
- Identity name (
Microsoft.PowerShell) - Identity publisher (
CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US)
These steps are then taken:
- UTF-16 encode the identity publisher
- Calculate a SHA256 hash of the encoded publisher
- Take the first 8 bytes of the hash
- Encode the result with Douglas Crockford Base32
- Join the identity name and the encoded value with an underscore (
Microsoft.PowerShell_8wekyb3d8bbwe)
§Why would I need to calculate a package family name?
Whilst this is a niche library, there are use cases. For example, when submitting an MSIX package to winget-pkgs, a package family name value is a required as part of the manifest.
§Acknowledgements
@marcinotorowski has produced a step by step explanation of how to calculate the hash part of the package family name. This post can be found here.
Structs§
- Package
Family Name - A Package Family Name is an opaque string derived from only two parts of a package identity - name and publisher.
- Publisher
Id - A Crockford Base32 encoded 13-character long Publisher Id derived from a Publisher.