class Gnosis::Translators::Key

Representation of the key used to decrypt files in an encrypted archive. The encryption method used by the RPG Maker series regularly mutates the key in order to provide encryption; this class provides a simple way to accurately manage these mutations.

Attributes

current[RW]

The current state of the encryption key.

key[RW]

The current state of the encryption key.

Public Class Methods

new(key = 0xDEADCAFE) click to toggle source

Creates a new instance of {Key Key} with the given {#key key} as the starting point for encryption.

@note The RPG Maker series uses ‘0xDEADCAFE` as the default starting

point for the encryption key unless the project uses a custom
encryption solution.
# File lib/gnosis/translators/key.rb, line 18
def initialize(key = 0xDEADCAFE)
  @key = key
end

Public Instance Methods

advance() click to toggle source

Mutates the encryption key to facilitate advancement through the archive this key belongs to.

@return [Fixnum] the next key sequence

# File lib/gnosis/translators/key.rb, line 26
def advance
  @key = (@key * 7 + 3) & 0xFFFFFFFF
end