Options
All
  • Public
  • Public/Protected
  • All
Menu

KeySAVCoreJS

This is a library for all your Pokémon Generation 6 and 7 breaking needs. It has support for exporting data from Powersaves backups/backups from digital copies, main files as well as battle videos. Basically, this is the logic part of KeySAV2 rewritten. Data is returned in the form of an object containing all relevant information about the Pokémon.

TypeScript definition files are provided and an API documentation is available.

Credits

Original exploit by Kaphotics and OmegaDonut used with permission. Thank you for all your hard work!

History

Originally I forked the KeySAV2 project to add some features, since then I refactored the code multiple times, extracted this code from the interface logic, ported it to JavaScript and have eventually rewritten it.

License

All code is Copyright 2014-2017 Tobias "Copper Phosphate" Zimmermann and distributed under the terms of the MIT license.
The Pokémon character names, stats and other data is Copyright 2002-2017 Pokémon, Copyright 1995-2017 Nintendo/Creatures Inc./GAME FREAK Inc.

Index

Type aliases

Stats

Stats: object[][]

Variables

eggnames

eggnames: string[] = ["タマゴ", "Egg", "Å’uf", "Uovo", "Ei", "", "Huevo", "알", "蛋", "蛋"]

Functions

base64Encode

  • base64Encode(arr: Uint8Array): string
  • Parameters

    • arr: Uint8Array

    Returns string

breakKey

  • breakKey(break1: Uint8Array, break2: Uint8Array): Promise<string>
  • Create a new key for the given saves.

    The two saves should satisfy the following:

    • Save 1 has six Pokémon in the first six slots of box one. After saving the game was reset and saved again.
    • Save 2 has the same Pokémon moved to box 2. It was not saved twice.

    If the second save was also saved twice, an old-style key will be created rather than a new-style key. This means that only one of the save slots in a save will be decrypted and the user will need to save twice on every save that should be dumped later.

    After creation the key will be stored in the global key store.

    Parameters

    • break1: Uint8Array

      The first save

    • break2: Uint8Array

      The second save

    Returns Promise<string>

    "CREATED_NEW" if a new-style key was created, "CREATED_OLD" if an old-style key was created

breakSavOrBv

  • breakSavOrBv(file1: Uint8Array, file2: Uint8Array): Promise<object>
  • Create or upgrade a key with the given files.

    Both files must be of the same type (battle video or save) and satisfy the requirements outlined in the relevant breakKey function.

    Parameters

    • file1: Uint8Array

      The first file to use

    • file2: Uint8Array

      The second file to use

    Returns Promise<object>

clear

  • clear(src: Uint8Array, offset: number, length: number): void
  • clear(src: Uint8Array): void
  • Parameters

    • src: Uint8Array
    • offset: number
    • length: number

    Returns void

  • Parameters

    • src: Uint8Array

    Returns void

copy

  • copy(src: Uint8Array, off1: number, dest: Uint8Array, off2: number, length: number): void
  • Parameters

    • src: Uint8Array
    • off1: number
    • dest: Uint8Array
    • off2: number
    • length: number

    Returns void

createBuffer

  • createBuffer(arr: Uint8Array | Uint16Array | Uint32Array): Buffer
  • Parameters

    • arr: Uint8Array | Uint16Array | Uint32Array

    Returns Buffer

createDataView

  • createDataView(arr: any): DataView
  • Parameters

    • arr: any

    Returns DataView

createNoKeyError

  • createNoKeyError(stamp: string, isSav: boolean): Error
  • Parameters

    • stamp: string
    • isSav: boolean

    Returns Error

createNotStoredKeyError

  • createNotStoredKeyError(stamp: string, isSav: boolean): Error
  • Parameters

    • stamp: string
    • isSav: boolean

    Returns Error

createUint16Array

  • createUint16Array(arr: any): Uint16Array
  • Parameters

    • arr: any

    Returns Uint16Array

createUint32Array

  • createUint32Array(arr: any): Uint32Array
  • Parameters

    • arr: any

    Returns Uint32Array

createUint8Array

  • createUint8Array(arr: any): Uint8Array
  • Parameters

    • arr: any

    Returns Uint8Array

decodeUnicode16LE

  • decodeUnicode16LE(arr: Uint8Array, offset: number, length: number): string
  • Parameters

    • arr: Uint8Array
    • offset: number
    • length: number

    Returns string

empty

  • empty(src: Uint8Array, offset: number, length: number): boolean
  • empty(src: Uint8Array): boolean
  • Parameters

    • src: Uint8Array
    • offset: number
    • length: number

    Returns boolean

  • Parameters

    • src: Uint8Array

    Returns boolean

encodeUnicode16LE

  • encodeUnicode16LE(str: string): Uint8Array
  • Parameters

    • str: string

    Returns Uint8Array

getKeyStore

getStampAndKindFromKey

  • getStampAndKindFromKey(arr: Uint8Array, size: number): object
  • Extract the stamp and key variation (save or battle video) from the first 0x18 bytes of a key and the file size.

    Parameters

    • arr: Uint8Array

      The first 0x18 byteo of the key

    • size: number

      The complete size of the key file

    Returns object

    an object containing the stamp for the key and the kind: 0 for saves, 1 for battle videos

getStampBv

  • getStampBv(arr: Uint8Array, off: number): string
  • Parameters

    • arr: Uint8Array
    • off: number

    Returns string

getStampSav

  • getStampSav(arr: Uint8Array, off: number): string
  • Parameters

    • arr: Uint8Array
    • off: number

    Returns string

load

  • load(input: Uint8Array): Promise<SaveReader>
  • Create and return a [[SaveReader]] for the given save file. The type of the file is automatically recognized and keys are retrieved from the global key store if neccessary.

    Parameters

    • input: Uint8Array

      The battle video to load

    Returns Promise<SaveReader>

    A promise for the created [[SaveReader]]

loadAllStats

loadGen6Stats

loadGen7Stats

loadLocalization

loadSavOrBv

  • loadSavOrBv(file: Uint8Array): Promise<object>
  • Load a given file. The file may be either a battle video or a save file.

    The appropriate key will be retrieved from the global keystore if possible, otherwise an error will be thrown.

    Parameters

    • file: Uint8Array

      The file to load.

    Returns Promise<object>

next

  • next(seed: any): number
  • Advance the linear congruential PRNG with the given seed. The parameters are hardcoded to what is used in the Pokémon games.

    Parameters

    • seed: any

      The seed to advance

    Returns number

    The next seed

pad4

  • pad4(n: number): string
  • Parameters

    • n: number

    Returns string

pad5

  • pad5(n: number): string
  • Parameters

    • n: number

    Returns string

promisify

  • promisify<T>(fn: function): function
  • promisify<T, A1>(fn: function): function
  • promisify<T, A1, A2>(fn: function): function
  • promisify<T, A1, A2, A3>(fn: function): function
  • promisify<T, A1, A2, A3, A4>(fn: function): function
  • promisify<T, A1, A2, A3, A4, A5>(fn: function): function
  • promisify<T, A1, A2, A3, A4, A5, A6>(fn: function): function
  • promisify<T, A1, A2, A3, A4, A5, A6, A7>(fn: function): function
  • Type parameters

    • T

    Parameters

    • fn: function
        • (cb: function): void
        • Parameters

          • cb: function
              • (err: Error, res?: T): void
              • Parameters

                • err: Error
                • Optional res: T

                Returns void

          Returns void

    Returns function

      • (): Promise<T>
      • Returns Promise<T>

  • Type parameters

    • T

    • A1

    Parameters

    • fn: function
        • (arg1: A1, cb: function): void
        • Parameters

          • arg1: A1
          • cb: function
              • (err: Error, res?: T): void
              • Parameters

                • err: Error
                • Optional res: T

                Returns void

          Returns void

    Returns function

      • (arg1: A1): Promise<T>
      • Parameters

        • arg1: A1

        Returns Promise<T>

  • Type parameters

    • T

    • A1

    • A2

    Parameters

    • fn: function
        • (arg1: A1, arg2: A2, cb: function): void
        • Parameters

          • arg1: A1
          • arg2: A2
          • cb: function
              • (err: Error, res?: T): void
              • Parameters

                • err: Error
                • Optional res: T

                Returns void

          Returns void

    Returns function

      • (arg1: A1, arg2: A2): Promise<T>
      • Parameters

        • arg1: A1
        • arg2: A2

        Returns Promise<T>

  • Type parameters

    • T

    • A1

    • A2

    • A3

    Parameters

    • fn: function
        • (arg1: A1, arg2: A2, arg3: A3, cb: function): void
        • Parameters

          • arg1: A1
          • arg2: A2
          • arg3: A3
          • cb: function
              • (err: Error, res?: T): void
              • Parameters

                • err: Error
                • Optional res: T

                Returns void

          Returns void

    Returns function

      • (arg1: A1, arg2: A2, arg3: A3): Promise<T>
      • Parameters

        • arg1: A1
        • arg2: A2
        • arg3: A3

        Returns Promise<T>

  • Type parameters

    • T

    • A1

    • A2

    • A3

    • A4

    Parameters

    • fn: function
        • (arg1: A1, arg2: A2, arg3: A3, arg4: A4, cb: function): void
        • Parameters

          • arg1: A1
          • arg2: A2
          • arg3: A3
          • arg4: A4
          • cb: function
              • (err: Error, res?: T): void
              • Parameters

                • err: Error
                • Optional res: T

                Returns void

          Returns void

    Returns function

      • (arg1: A1, arg2: A2, arg3: A3, arg4: A4): Promise<T>
      • Parameters

        • arg1: A1
        • arg2: A2
        • arg3: A3
        • arg4: A4

        Returns Promise<T>

  • Type parameters

    • T

    • A1

    • A2

    • A3

    • A4

    • A5

    Parameters

    • fn: function
        • (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, cb: function): void
        • Parameters

          • arg1: A1
          • arg2: A2
          • arg3: A3
          • arg4: A4
          • arg5: A5
          • cb: function
              • (err: Error, res?: T): void
              • Parameters

                • err: Error
                • Optional res: T

                Returns void

          Returns void

    Returns function

      • (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5): Promise<T>
      • Parameters

        • arg1: A1
        • arg2: A2
        • arg3: A3
        • arg4: A4
        • arg5: A5

        Returns Promise<T>

  • Type parameters

    • T

    • A1

    • A2

    • A3

    • A4

    • A5

    • A6

    Parameters

    • fn: function
        • (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, arg6: A6, cb: function): void
        • Parameters

          • arg1: A1
          • arg2: A2
          • arg3: A3
          • arg4: A4
          • arg5: A5
          • arg6: A6
          • cb: function
              • (err: Error, res?: T): void
              • Parameters

                • err: Error
                • Optional res: T

                Returns void

          Returns void

    Returns function

      • (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, arg6: A6): Promise<T>
      • Parameters

        • arg1: A1
        • arg2: A2
        • arg3: A3
        • arg4: A4
        • arg5: A5
        • arg6: A6

        Returns Promise<T>

  • Type parameters

    • T

    • A1

    • A2

    • A3

    • A4

    • A5

    • A6

    • A7

    Parameters

    • fn: function
        • (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, arg6: A6, arg7: A7, cb: function): void
        • Parameters

          • arg1: A1
          • arg2: A2
          • arg3: A3
          • arg4: A4
          • arg5: A5
          • arg6: A6
          • arg7: A7
          • cb: function
              • (err: Error, res?: T): void
              • Parameters

                • err: Error
                • Optional res: T

                Returns void

          Returns void

    Returns function

      • (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, arg6: A6, arg7: A7): Promise<T>
      • Parameters

        • arg1: A1
        • arg2: A2
        • arg3: A3
        • arg4: A4
        • arg5: A5
        • arg6: A6
        • arg7: A7

        Returns Promise<T>

registerPkmImpl

  • registerPkmImpl(generation: number, impl: object): void
  • Register an implementation of a generation specific specialization of PkBase.

    Parameters

    • generation: number

      The generation this specialization is for

    • impl: object

      The implementation of the specialization

    Returns void

sequenceEqual

  • sequenceEqual(src1: Uint8Array, src2: Uint8Array): boolean
  • sequenceEqual(src1: Uint8Array, src2: Uint8Array, offset: number): boolean
  • sequenceEqual(src1: Uint8Array, off1: number, src2: Uint8Array, off2: number, length: number): boolean
  • Parameters

    • src1: Uint8Array
    • src2: Uint8Array

    Returns boolean

  • Parameters

    • src1: Uint8Array
    • src2: Uint8Array
    • offset: number

    Returns boolean

  • Parameters

    • src1: Uint8Array
    • off1: number
    • src2: Uint8Array
    • off2: number
    • length: number

    Returns boolean

setKeyStore

  • Set the global key store. It is used by utility functions to store and retrieve keys for provided saves and battle videos.

    Parameters

    • store: KeyStore

      The key store to be used globally

    Returns void

xor

  • xor(src1: Uint8Array, src2: Uint8Array): Uint8Array
  • xor(src1: Uint8Array, src2: Uint8Array, length: number): Uint8Array
  • xor(src1: Uint8Array, off1: number, src2: Uint8Array, off2: number, len: number): Uint8Array
  • xor(src1: Uint8Array, off1: number, src2: Uint8Array, off2: number, dest: Uint8Array, off3: number, len: number): void
  • Parameters

    • src1: Uint8Array
    • src2: Uint8Array

    Returns Uint8Array

  • Parameters

    • src1: Uint8Array
    • src2: Uint8Array
    • length: number

    Returns Uint8Array

  • Parameters

    • src1: Uint8Array
    • off1: number
    • src2: Uint8Array
    • off2: number
    • len: number

    Returns Uint8Array

  • Parameters

    • src1: Uint8Array
    • off1: number
    • src2: Uint8Array
    • off2: number
    • dest: Uint8Array
    • off3: number
    • len: number

    Returns void

xorInPlace

  • xorInPlace(dest: Uint8Array, off1: number, src: Uint8Array, off2: number, length: number): void
  • Parameters

    • dest: Uint8Array
    • off1: number
    • src: Uint8Array
    • off2: number
    • length: number

    Returns void

xorThree

  • xorThree(src1: Uint8Array, off1: number, src2: Uint8Array, off2: number, src3: Uint8Array, off3: number, length: number): Uint8Array
  • Parameters

    • src1: Uint8Array
    • off1: number
    • src2: Uint8Array
    • off2: number
    • src3: Uint8Array
    • off3: number
    • length: number

    Returns Uint8Array

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc