Genesis Classic Key Converter

Genesis Classic Key Converter

Genesis ID Conversion

A Python utility that converts Genesis Classic GUIDs to their corresponding Genesis Classic integer IDs (Legacy Keys), enabling accurate matching of items between Genesis Classic and Genesis Foods.

Background

Genesis Foods identifies food entities using GUIDs derived deterministically from Genesis Classic integer IDs (Legacy Keys). This utility converts a Genesis Classic GUID back to its original Legacy Key, enabling the item to be matched to the corresponding entity in Genesis Foods.

Requirements

  • Python 3.9+

  • No third-party dependencies (uses only hashlib, struct, and uuid from the standard library)

Command Line Usage

Extract: Genesis Classic GUID → Legacy ID

bash

python genesis_id_conversion.py extract <guid>

Example:

bash

python genesis_id_conversion.py extract 550e8400-e29b-41d4-a716-446655440000 # Legacy Classic ID: 12345

Derive : Legacy ID → Genesis Classic GUID

bash

python genesis_id_conversion.py derive [ingredient|recipe|composite] <legacy_id>

Examples:

bash

python genesis_id_conversion.py derive ingredient 12345 # Genesis Classic GUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx python genesis_id_conversion.py derive recipe 12345 # Genesis Classic GUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx python genesis_id_conversion.py derive composite 12345 # Genesis Classic GUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Usage as a Module

python

from genesis_id_conversion import extract_legacy_id, derive_guid, FoodType # GUID → Legacy ID keys = extract_legacy_id("550e8400-e29b-41d4-a716-446655440000") print(keys[0]) # e.g. 12345 # Legacy ID → GUID guid = derive_guid(FoodType.INGREDIENT, 12345) guid = derive_guid(FoodType.RECIPE, 12345) guid = derive_guid(FoodType.COMPOSITE_INGREDIENT, 12345)

Appendix

API

extract_legacy_id(guid_str, key_part_count=1)

Extracts legacy Classic ID(s) from a Genesis Foods GUID.

Parameter

Type

Default

Description

Parameter

Type

Default

Description

guid_str

str

required

Genesis Foods GUID string (standard hyphenated format)

key_part_count

int

1

Number of legacy key parts to extract (1–3)

Returns: list[int] — signed 32-bit legacy ID(s).

Raises:

  • ValueError — if key_part_count is not between 1 and 3

  • ValueError — if guid_str is not a valid GUID string


derive_guid(food_type, legacy_id)

Derives a Genesis Classic GUID from a food type and legacy Classic integer ID.

Parameter

Type

Description

Parameter

Type

Description

food_type

FoodType

The food entity type (INGREDIENT, RECIPE, or COMPOSITE_INGREDIENT)

legacy_id

int

Legacy Genesis Classic integer ID

Returns: str — Genesis Foods GUID string.


FoodType (Enum)

Member

URN

Member

URN

FoodType.INGREDIENT

http://ns.esha.com/2013/Ingredient

FoodType.RECIPE

http://ns.esha.com/2013/Recipe

FoodType.COMPOSITE_INGREDIENT

http://ns.esha.com/2013/CompositeIngredient

Notes

Round-trip Consistency

The two operations are fully reversible for the same food type:

python

derive_guid(FoodType.INGREDIENT, extract_legacy_id(guid)[0]) == guid extract_legacy_id(derive_guid(FoodType.INGREDIENT, legacy_id))[0] == legacy_idz

 

Connecting Legacy ID within Genesis Foods

Once you have the LegacyKey you can do a Search on Foods and the FoodSearchInput should include the LegacyKey as the searchText and  LegacyKey as the SearchFieldFilter.

Download

 

Clicking links may navigate you away from the Trustwell site.