Merkle–Hellman knapsack cryptosystem
The Merkle–Hellman knapsack cryptosystem was one of the earliest public key cryptosystems invented by Ralph Merkle and Martin Hellman in 1978. The ideas behind it are simpler than those involving RSA, and it has been broken. Source: © WikiPedia
Installation
Via npm:
npm i merkle-hellman
via yarn:
yarn add merkle-hellman
⚠️ Attention!
Do not use this system in projects where a cryptographic encryption algorithm is required. The crypto-system is easy to be cracked
Usage
Use Encoder
class and encode
method for encoding source message
Use Decoder
class and decode
method for decoding encoded message
Use Cracker
class and crack
method for getting secret key from public key
Example
Encoding/Decoding messages:
; ;; ; ;; console.log`Source message: `;console.log`Encoded message: `;console.log`Decoded message: `;
Cracking public key:
; ;;;; ;;; ; ; ; ;; console.log`Source message: `;console.log`Encoded message: `;console.log`Decoded message: `; console.log; console.log`Public key: `;console.log`Secret key: `;console.log`Cracked secret key: `;