Skip to main content

Cipher library for encryption methods found on Chinese Gold Bars

Project description

cgbenigma

This package contains Python files that utilize encryption methods reverse-engineered from cryptograms found on Chinese Gold Bars. In the 1930s, some Chinese individuals deposited three hundred million US dollars into a branch of the National City Bank in Shanghai. In return, the bank issued several gold bars as certificates of the transaction. These gold bars were inscribed with plain Chinese characters and cryptograms. The existence of the Chinese Gold Bars gained attention on the Internet through a blog published on the IACR web site around 2009. The presumed owner of these gold bars, known as Bin-Jiang Tao filed a lawsuit against Citibank to recover the deposited funds; however, the court ruled in favor of Citibank, and the claim was denied. The actual audio of the oral argument between Bin-Jiang Tao and Citibank can be accessed at this link. Recently, the cryptograms have been decrypted, and the methods used to generate the cryptograms have also been reverse-engineered and documented here.

CGB (Chinese Gold Bar) ciphers were presumably created with a Swiss-K Enigma machine. None of the CGB cryptograms exceed 26 alphabet characters. CGB ciphers are also multiply encrypted. In other words, after a piece of plain text was encrypted, another piece of plain text is added to form a new message for the next encryption. The decrypted results show that some CGB ciphers have been encrypted three times in a row by adding extra words to produce the final cryptogram. The more a message is encrypted, the more important information it carries.

To decrypt a CGB cipher, two parameters need to be chosen: the KEY and the RING values. CGB ciphers introduced a new method to further reduce the number of parameters down to just one. In other words, a CGB cipher can be decrypted using only the KEY value, without needing the RING value. Some CGB ciphers are generated in such a way that the last three letters of the cryptogram are used as the RING value for decryption.

Install Library

py -m pip install cgbenigma

Examples

Case 1. Encrypt a plaintext "HELLOWORLD" with KEY ("AAA") and RING ("BBB") values.

cgblib.encrypt("HELLOWORLD", "AAA", "BBB")
[{'Key': 'AAA', 'Ring': 'BBB', 'Message': 'HELLOWORLD', 'Cipher': 'SYVEDJVFMT'}]
cgblib.decrypt("SYVEDJVFMT", "AAA", "BBB")
HELLOWORLD

The cipher SYVEDJVFMT can be deciphered with the KEY ("AAA") and RING ("BBB") values to recover the text "HELLOWORLD".

Case 2. Encrypt a plaintext "HELLOWORLD" with the RING value.

cgblib.encrypt("HELLOWORLD", "XXX")
Key-Ring cipher tuple(s) found: 2
[{'Key': 'CFY', 'Ring': 'XXX', 'Message': 'HELLOWORLD', 'Cipher': 'RBTUTBUXXX'}, {'Key': 'HDO', 'Ring': 'XXX', 'Message': 'HELLOWORLD', 'Cipher': 'WXMARVWXXX'}]

If a single key value is entered, it will be used as not the KEY, but the RING value for the ciphertext. In this case, the last 3 letters of the generated cipher will be the same as the provided key value. The assignment of the key value is arbitrary and there may be no resultant cipher ending with the provided key value.

cgblib.encrypt("HELLOWORLD", "AAA")
There is no key-ring cipher tuple with the given ring, AAA
[]

When the provided key value was "AAA", there is no cipher ending with "AAA". If the provided key value was "XXX", there are two ciphers ending with "XXX" as presented above. In that case, the original plaintext can be recovered with the KEY value and the last 3 letters of the cipher is used as the RING value.

cgblib.decrypt("WXMARVWXXX", "HDO")
'HELLOWORLD'
cgblib.decrypt("RBTUTBUXXX", "CFY")
'HELLOWORLD'

The cipher "WXMARVWXXX" is decrypted with the KEY "HDO". The cipher "RBTUTBUXXX" is decoded with the KEY "CFY".

Case 3. Find ciphers that contain the provided string in its decrypted text.

cgblib.find(["FEWGDRHDDEEUMFFTEEMJXZR"], ["BANK"])
[{'Key': 'CGX', 'Ring': 'XZR', 'Message': 'DDVTBZTZOADREBANKQTZQMD', 'Cipher': 'FEWGDRHDDEEUMFFTEEMJXZR'}, {'Key': 'GPV', 'Ring': 'XZR', 'Message': 'OUSTGOVPBANKIZMUBMHUVOG', 'Cipher': 'FEWGDRHDDEEUMFFTEEMJXZR'}, {'Key': 'HWS', 'Ring': 'XZR', 'Message': 'BANKUPCWXJKZEZPFSVJRLDH', 'Cipher': 'FEWGDRHDDEEUMFFTEEMJXZR'}]

It checks if the decrypted text contains BANK while changing the KEY value from AAA to ZZZ. The last three letters of the cipher XZR is used as the RING value.

cgblib.find(["FEWGDRHDDEEUMFFTEEMJXZR"], ["BANK"], "AAA")
[{'Key': 'CVU', 'Ring': 'AAA', 'Message': 'MKXBFBANKODXXRTMOQTDHQD', 'Cipher': 'FEWGDRHDDEEUMFFTEEMJXZR'}, {'Key': 'FHG', 'Ring': 'AAA', 'Message': 'DWQRBZTZOADREBANKQTZQMD', 'Cipher': 'FEWGDRHDDEEUMFFTEEMJXZR'}, {'Key': 'JQE', 'Ring': 'AAA', 'Message': 'OUSTGOVPBANKIZMUBMHUVOG', 'Cipher': 'FEWGDRHDDEEUMFFTEEMJXZR'}, {'Key': 'KXB', 'Ring': 'AAA', 'Message': 'BANKUPCWXJKZEZPFSVJRLDI', 'Cipher': 'FEWGDRHDDEEUMFFTEEMJXZR'}]

When a specific value was provided, it will be used as the RING value.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cgbenigma-0.0.6.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cgbenigma-0.0.6-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file cgbenigma-0.0.6.tar.gz.

File metadata

  • Download URL: cgbenigma-0.0.6.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for cgbenigma-0.0.6.tar.gz
Algorithm Hash digest
SHA256 af8964a6f354011df83b7cee47a462956108d97be543803903b2dab304c4f41b
MD5 880355db1e778908a0cbee8db183852d
BLAKE2b-256 64a16f6bedf0f0dc27c4432d721f5efd469541c9dbe85975e5250247a6f2681f

See more details on using hashes here.

File details

Details for the file cgbenigma-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: cgbenigma-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for cgbenigma-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 fbb12f98d22b25d8796e49b7b1485d0165aabf5de33c5a01b0fac5f29916e9a6
MD5 684c44eedc3f5b492c5d29880735c5ac
BLAKE2b-256 258b1e6b83551107268bbdf79f1ae7173564485baf134e8025c7c7be6f354b65

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page