mwg API
    Preparing search index...

    Function scramble

    • XOR-with-a-key text scrambling. This is explicitly not encryption and must never be presented to a player or a game's own documentation as one: it stops a save being hand-edited by someone opening it in a text editor, and deliberately nothing stronger - the key is recoverable from the scrambled text plus any known plaintext fragment, the classic XOR weakness, accepted on purpose rather than overlooked. Reach for this only where "not trivially editable" is the actual requirement, per SaveSystem.exportSlot's own use of it.

      Parameters

      • text: string
      • key: string

      Returns string

      import { scramble, unscramble } from '@datamoc/mw_games/core';

      const scrambled = scramble('{"depth":3}', 'a-per-game-key');
      const restored = unscramble(scrambled, 'a-per-game-key'); // '{"depth":3}'