{"_id":"@bangjelkoski/eth-crypto","_rev":"1-c91d3fd0b4561cbfee78ccc019497cd9","name":"@bangjelkoski/eth-crypto","dist-tags":{"latest":"2.6.1"},"versions":{"2.6.0":{"name":"@bangjelkoski/eth-crypto","version":"2.6.0","description":"Cryptographic functions for ethereum and how to use them with web3 and solidity","keywords":["ethereum","eth","web3","solidity","encryption","secp256k1","dapp","blockchain","ecies","smart-contract","identity","signature"],"main":"./dist/lib/index.js","jsnext:main":"./dist/es/index.js","module":"./dist/es/index.js","types":"./typings/index.d.ts","scripts":{"test":"npm run test:node && npm run test:browser","test:node":"npm run build && mocha ./test/index.test.js -b --timeout 6000 --exit","test:browser":"npm run build && karma start ./config/karma.conf.js --single-run","test:size":"npm run build && rimraf test_tmp/browserify.js && browserify --no-builtins dist/lib/browserify.index.js > test_tmp/browserify.js && uglifyjs --compress --mangle --output test_tmp/browserify.min.js -- test_tmp/browserify.js && echo \"Build-Size (minified+gzip):\" && gzip-size --raw test_tmp/browserify.min.js","test:typings":"npm run build && mocha ./test/typings.test.js -b --timeout 12000 --exit","test:deps":"dependency-check ./package.json --no-dev --unused --ignore-module @types/bn.js","lint":"eslint --ignore-path .eslintignore src test config && solhint \"contracts/**/*.sol\"","clear":"rimraf -rf ./dist && rimraf -rf ./gen && rimraf -rf ./test_tmp","build:sol":"solidity-cli -i './contracts/*.sol' -o ./gen","build:es6":"rimraf -rf dist/es && cross-env NODE_ENV=es6 babel src --out-dir dist/es","build:es5":"babel src --out-dir dist/lib","build:test":"babel test --out-dir test_tmp","build":"npm run clear && concurrently \"npm run build:es6\" \"npm run build:es5\" \"npm run build:test\" \"npm run build:sol\"","build:webpack":"npm run build && cross-env NODE_ENV=build webpack --config ./config/webpack.config.js","build:size":"npm run build:webpack && echo \"Build-Size (minified+gzip):\" && gzip-size --raw ./test_tmp/webpack.bundle.js","disc":"npm run build && cross-env NODE_ENV=disc webpack --config ./config/webpack.config.js"},"repository":{"type":"git","url":"git+https://github.com/pubkey/eth-crypto.git"},"author":{"name":"pubkey"},"funding":"https://github.com/sponsors/pubkey","license":"MIT","bugs":{"url":"https://github.com/pubkey/eth-crypto/issues"},"homepage":"https://github.com/pubkey/eth-crypto#readme","devDependencies":{"@babel/cli":"7.23.0","@babel/core":"7.23.2","@babel/plugin-transform-runtime":"7.23.2","@babel/preset-env":"7.23.2","assert":"2.1.0","async-test-util":"2.2.1","babel-loader":"9.1.3","bn.js":"5.2.1","browserify":"17.0.0","concurrently":"8.2.2","convert-hrtime":"5.0.0","cross-env":"7.0.3","dependency-check":"4.1.0","disc":"1.3.3","eslint":"8.53.0","ganache-cli":"6.12.2","gzip-size-cli":"5.1.0","is-node":"1.0.2","js-sha3":"0.9.2","karma":"6.4.2","karma-babel-preprocessor":"8.0.2","karma-browserify":"8.1.0","karma-chrome-launcher":"3.2.0","karma-coverage":"2.2.1","karma-detect-browsers":"2.3.3","karma-edge-launcher":"0.4.2","karma-firefox-launcher":"2.1.2","karma-ie-launcher":"1.0.0","karma-mocha":"2.0.1","karma-opera-launcher":"1.0.0","karma-safari-launcher":"1.0.0","mocha":"10.2.0","rimraf":"4.4.1","solhint":"4.0.0","solidity-cli":"1.0.3","terser-webpack-plugin":"5.3.9","ts-node":"10.9.1","typescript":"5.2.2","uglify-es":"3.3.9","web3":"1.10.3","webpack":"5.75.0","webpack-bundle-analyzer":"4.9.1","webpack-cli":"5.1.4","stream-browserify":"3.0.0","crypto-browserify":"3.12.0"},"dependencies":{"@babel/runtime":"7.23.2","@ethereumjs/tx":"3.5.2","@types/bn.js":"5.1.4","@toruslabs/eccrypto":"1.1.8","ethereumjs-util":"7.1.5","ethers":"5.7.2","secp256k1":"5.0.0"},"gitHead":"28b43cee411175ed9a20e667d041b5d3f9eec3d2","_id":"@bangjelkoski/eth-crypto@2.6.0","_nodeVersion":"16.20.0","_npmVersion":"8.19.4","dist":{"integrity":"sha512-7hBClpUYG3lz+dxawFuuiwVu3LNkKBWXiI5Wkf6ZPnghyTpjghhbIyPBOVbQokJxbjfjf2UQkSRLOd8L+xI3Ng==","shasum":"4879de7c6f45a8c8aebac1c47fcbcb531d302be4","tarball":"https://registry.npmjs.org/@bangjelkoski/eth-crypto/-/eth-crypto-2.6.0.tgz","fileCount":44,"unpackedSize":56487,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCaDiPKEd33/DbMTzqFu0OfF6gyi92//1mbVzXIWtT5HAIgRNxQEqVF5rB5jDO2d8+WcXOXk6LwfOTZXFhXl2KJdIM="}]},"_npmUser":{"name":"bangjelkoski","email":"bangjelkoskii@gmail.com"},"directories":{},"maintainers":[{"name":"bangjelkoski","email":"bangjelkoskii@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eth-crypto_2.6.0_1699284430783_0.30886369329980523"},"_hasShrinkwrap":false},"2.6.1":{"name":"@bangjelkoski/eth-crypto","version":"2.6.1","description":"Cryptographic functions for ethereum and how to use them with web3 and solidity","keywords":["ethereum","eth","web3","solidity","encryption","secp256k1","dapp","blockchain","ecies","smart-contract","identity","signature"],"main":"./dist/lib/index.js","jsnext:main":"./dist/es/index.js","module":"./dist/es/index.js","types":"./typings/index.d.ts","scripts":{"test":"npm run test:node && npm run test:browser","test:node":"npm run build && mocha ./test/index.test.js -b --timeout 6000 --exit","test:browser":"npm run build && karma start ./config/karma.conf.js --single-run","test:size":"npm run build && rimraf test_tmp/browserify.js && browserify --no-builtins dist/lib/browserify.index.js > test_tmp/browserify.js && uglifyjs --compress --mangle --output test_tmp/browserify.min.js -- test_tmp/browserify.js && echo \"Build-Size (minified+gzip):\" && gzip-size --raw test_tmp/browserify.min.js","test:typings":"npm run build && mocha ./test/typings.test.js -b --timeout 12000 --exit","test:deps":"dependency-check ./package.json --no-dev --unused --ignore-module @types/bn.js","lint":"eslint --ignore-path .eslintignore src test config && solhint \"contracts/**/*.sol\"","clear":"rimraf -rf ./dist && rimraf -rf ./gen && rimraf -rf ./test_tmp","build:sol":"solidity-cli -i './contracts/*.sol' -o ./gen","build:es6":"rimraf -rf dist/es && cross-env NODE_ENV=es6 babel src --out-dir dist/es","build:es5":"babel src --out-dir dist/lib","build:test":"babel test --out-dir test_tmp","build":"npm run clear && concurrently \"npm run build:es6\" \"npm run build:es5\" \"npm run build:test\" \"npm run build:sol\"","build:webpack":"npm run build && cross-env NODE_ENV=build webpack --config ./config/webpack.config.js","build:size":"npm run build:webpack && echo \"Build-Size (minified+gzip):\" && gzip-size --raw ./test_tmp/webpack.bundle.js","disc":"npm run build && cross-env NODE_ENV=disc webpack --config ./config/webpack.config.js"},"repository":{"type":"git","url":"git+https://github.com/pubkey/eth-crypto.git"},"author":{"name":"pubkey"},"funding":"https://github.com/sponsors/pubkey","license":"MIT","bugs":{"url":"https://github.com/pubkey/eth-crypto/issues"},"homepage":"https://github.com/pubkey/eth-crypto#readme","devDependencies":{"@babel/cli":"7.23.0","@babel/core":"7.23.2","@babel/plugin-transform-runtime":"7.23.2","@babel/preset-env":"7.23.2","assert":"2.1.0","async-test-util":"2.2.1","babel-loader":"9.1.3","bn.js":"5.2.1","browserify":"17.0.0","concurrently":"8.2.2","convert-hrtime":"5.0.0","cross-env":"7.0.3","dependency-check":"4.1.0","disc":"1.3.3","eslint":"8.53.0","ganache-cli":"6.12.2","gzip-size-cli":"5.1.0","is-node":"1.0.2","js-sha3":"0.9.2","karma":"6.4.2","karma-babel-preprocessor":"8.0.2","karma-browserify":"8.1.0","karma-chrome-launcher":"3.2.0","karma-coverage":"2.2.1","karma-detect-browsers":"2.3.3","karma-edge-launcher":"0.4.2","karma-firefox-launcher":"2.1.2","karma-ie-launcher":"1.0.0","karma-mocha":"2.0.1","karma-opera-launcher":"1.0.0","karma-safari-launcher":"1.0.0","mocha":"10.2.0","rimraf":"4.4.1","solhint":"4.0.0","solidity-cli":"1.0.3","terser-webpack-plugin":"5.3.9","ts-node":"10.9.1","typescript":"5.2.2","uglify-es":"3.3.9","web3":"1.10.3","webpack":"5.75.0","webpack-bundle-analyzer":"4.9.1","webpack-cli":"5.1.4","stream-browserify":"3.0.0","crypto-browserify":"3.12.0"},"dependencies":{"@babel/runtime":"7.23.2","@ethereumjs/tx":"3.5.2","@types/bn.js":"5.1.4","@toruslabs/eccrypto":"2.1.1","ethereumjs-util":"7.1.5","ethers":"5.7.2","secp256k1":"5.0.0"},"gitHead":"28b43cee411175ed9a20e667d041b5d3f9eec3d2","_id":"@bangjelkoski/eth-crypto@2.6.1","_nodeVersion":"16.20.0","_npmVersion":"8.19.4","dist":{"integrity":"sha512-DnsK0EnWUA66tjICteIj7Ixyp9cgSo0s9YiyFJoosBtIVLn9Vsy/oD3iQUmKu9eF2bEXXJnbZnK3/rMDXuccnA==","shasum":"246e73c4cc10863d20f8541b9f4e02251767f309","tarball":"https://registry.npmjs.org/@bangjelkoski/eth-crypto/-/eth-crypto-2.6.1.tgz","fileCount":44,"unpackedSize":56487,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEjsPYDnD2qIF010uZ5SB/2DYFSkb0bjvtxGrs4Iw65gAiBx9JoxA9PB7PjYMfdkhVY2EAz30fI9EXguZ/qi6xaiyw=="}]},"_npmUser":{"name":"bangjelkoski","email":"bangjelkoskii@gmail.com"},"directories":{},"maintainers":[{"name":"bangjelkoski","email":"bangjelkoskii@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eth-crypto_2.6.1_1699351775242_0.5791651293865117"},"_hasShrinkwrap":false}},"time":{"created":"2023-11-06T15:27:10.711Z","2.6.0":"2023-11-06T15:27:10.959Z","modified":"2023-11-07T10:09:35.696Z","2.6.1":"2023-11-07T10:09:35.518Z"},"maintainers":[{"name":"bangjelkoski","email":"bangjelkoskii@gmail.com"}],"description":"Cryptographic functions for ethereum and how to use them with web3 and solidity","homepage":"https://github.com/pubkey/eth-crypto#readme","keywords":["ethereum","eth","web3","solidity","encryption","secp256k1","dapp","blockchain","ecies","smart-contract","identity","signature"],"repository":{"type":"git","url":"git+https://github.com/pubkey/eth-crypto.git"},"author":{"name":"pubkey"},"bugs":{"url":"https://github.com/pubkey/eth-crypto/issues"},"license":"MIT","readme":"<p align=\"center\">\n    <a href=\"https://twitter.com/pubkeypubkey\">\n        <img src=\"https://img.shields.io/twitter/follow/pubkeypubkey.svg?style=social&logo=twitter\"\n            alt=\"follow on Twitter\">\n    </a>\n</p>\n\n# eth-crypto\n\nCryptographic javascript-functions for ethereum and tutorials on how to use them together with web3js and solidity.\n\n## Tutorials\n\n- **[Creating keys and use them for ethereum transactions](./tutorials/creating-transactions.md)**\n\n  In this tutorial we will create an ethereum-identity and use it to send transactions to the blockchain.\n\n- **[Sign and validate data with solidity](./tutorials/signed-data.md)**\n\n  In this tutorial we will sign data in javascript and validate the signature inside of a smart-contract.\n\n- **[Sending encrypted and signed data to other identites](./tutorials/encrypted-message.md)**  \n\n  In this tutorial we will use the ethereum-identites and asymmetric cryptography to send an encrypted and signed message from Alice to Bob.\n\n## Sponsored by\n\n<p align=\"center\">\n    <a href=\"https://rxdb.info/?utm_source=github&utm_medium=repo&utm_campaign=github-eth-crypto-readme\">\n        <img\n            src=\"https://rxdb.info/files/logo/logo_text.svg\"\n            alt=\"JavaScript Database\"\n            width=\"300\"\n         />\n         <br />\n         <br />\n         <span>The <b>JavaScript Database</b></span>\n    </a>\n</p>\n\n## Using eth-crypto\n\n### Install\n\n```bash\n  npm install eth-crypto --save\n```\n\n```javascript\n// es6\nimport EthCrypto from 'eth-crypto';\n\n// node\nconst EthCrypto = require('eth-crypto');\n```\n\n## API\n\n- [createIdentity()](#createidentity)\n- [publicKeyByPrivateKey()](#publickeybyprivatekey)\n- [publicKey.toAddress()](#publickeytoaddress)\n- [publicKey.compress()](#publickeycompress)\n- [publicKey.decompress()](#publickeydecompress)\n- [sign()](#sign)\n- [recover()](#recover)\n- [recoverPublicKey()](#recoverpublickey)\n- [encryptWithPublicKey()](#encryptwithpublickey)\n- [decryptWithPrivateKey()](#decryptwithprivatekey)\n- [cipher.stringify()](#cipherstringify)\n- [cipher.parse()](#cipherparse)\n- [signTransaction()](#signtransaction)\n- [txDataByCompiled()](#txdatabycompiled)\n- [calculateContractAddress()](#calculatecontractaddress)\n- [hex.compress() hex.decompress()](#hex-compressdecompress)\n### createIdentity()\n\nCreates a new ethereum-identity with privateKey, publicKey and address as hex-string.\n\n```javascript\n  const identity = EthCrypto.createIdentity();\n  /* > {\n      address: '0x3f243FdacE01Cfd9719f7359c94BA11361f32471',\n      privateKey: '0x107be946709e41b7895eea9f2dacf998a0a9124acbb786f0fd1a826101581a07',\n      publicKey: 'bf1cc3154424dc22191941d9f4f50b063a2b663a2337e5548abea633c1d06ece...'\n  } */\n```\n\nYou can also create an identity by providing your own entropy-buffer. Use this with caution, a bad entropy can result in an unsecure private key.\n\n```javascript\n  const entropy = Buffer.from('f2dacf...', 'utf-8'); // must contain at least 128 chars\n  const identity = EthCrypto.createIdentity(entropy);\n  /* > {\n      address: '0x59c8d4d645B0a3b230DE368d815ebDE372d37Ea8',\n      privateKey: '0x18cea40e44624867ddfd775b2898cdb2da29b4be92ee072b9eb02d43b6f2473a',\n      publicKey: '991ce4643653ef452327ee3d1a56af19c84599d340ffd427e784...'\n  } */\n```\n\n### publicKeyByPrivateKey()\n\nDerives the publicKey from a privateKey and returns it as hex-string.\n\n```javascript\n  const publicKey = EthCrypto.publicKeyByPrivateKey(\n      '0x107be946709e41b7895eea9f2dacf998a0a9124acbb786f0fd1a826101581a07'\n  );\n  // > 'bf1cc3154424dc22191941d9f4f50b063a2b663a2337e5548abea633c1d06ece...'\n```\n\n### publicKey.toAddress()\n\nDerives the ethereum-address from the publicKey.\n\n```javascript\n  const address = EthCrypto.publicKey.toAddress(\n      'bf1cc3154424dc22191941d9f4f50b063a2b663a2337e5548abea633c1d06ece...'\n  );\n  // > '0x3f243FdacE01Cfd9719f7359c94BA11361f32471'\n```\n\n### publicKey.compress()\n\nCompresses an uncompressed publicKey.\n\n```javascript\n  const address = EthCrypto.publicKey.compress(\n      '04a34d6aef3eb42335fb3cacb59...'\n  );\n  // > '03a34d6aef3eb42335fb3cacb59478c0b44c0bbeb8bb4ca427dbc7044157a5d24b' // compressed keys start with '02' or '03'\n```\n\n### publicKey.decompress()\n\nDecompresses a compressed publicKey.\n\n```javascript\n  const address = EthCrypto.publicKey.decompress(\n      '03a34d6aef3eb42335fb3c...'\n  );\n  // > 'a34d6aef3eb42335fb3cacb5947' // non-compressed keys start with '04' or no prefix\n```\n\n### sign()\n\nSigns the hash with the privateKey. Returns the signature as hex-string.\n\n```javascript\n  const message = 'foobar';\n  const messageHash = EthCrypto.hash.keccak256(message);\n  const signature = EthCrypto.sign(\n      '0x107be946709e41b7895eea9f2dacf998a0a9124acbb786f0fd1a826101581a07', // privateKey\n      messageHash // hash of message\n  );\n  // > '0xc04b809d8f33c46ff80c44ba58e866ff0d5..'\n```\n\n### recover()\n\nRecovers the signers address from the signature.\n\n```javascript\n    const signer = EthCrypto.recover(\n      '0xc04b809d8f33c46ff80c44ba58e866ff0d5..',\n      EthCrypto.hash.keccak256('foobar') // signed message hash\n  );\n  // > '0x3f243FdacE01Cfd9719f7359c94BA11361f32471'\n```\n\n### recoverPublicKey()\n\nRecovers the signers `publicKey` from the signature.\n```javascript\n    const signer = EthCrypto.recoverPublicKey(\n      '0xc04b809d8f33c46ff80c44ba58e866ff0d5..', // signature\n      EthCrypto.hash.keccak256('foobar') // message hash\n  );\n  // > 'bf1cc3154424dc22191941d9f4f50b063a2b663a2337e5548abea633c1d06ece..'\n```\n\n\n### encryptWithPublicKey()\n\nEncrypts the message with the publicKey so that only the corresponding privateKey can decrypt it. Returns (async) the encrypted data as object with hex-strings.\n\n```javascript\n    const encrypted = await EthCrypto.encryptWithPublicKey(\n        'bf1cc3154424dc22191941d9f4f50b063a2b663a2337e5548abea633c1d06ece...', // publicKey\n        'foobar' // message\n    );\n    /* >  {\n            iv: '02aeac54cb45283b427bd1a5028552c1',\n            ephemPublicKey: '044acf39ed83c304f19f41ea66615d7a6c0068d5fc48ee181f2fb1091...',\n            ciphertext: '5fbbcc1a44ee19f7499dbc39cfc4ce96',\n            mac: '96490b293763f49a371d3a2040a2d2cb57f246ee88958009fe3c7ef2a38264a1'\n        } */\n```\n\n### decryptWithPrivateKey()\n\nDecrypts the encrypted data with the privateKey. Returns (async) the message as string.\n\n```javascript\n    const message = await EthCrypto.decryptWithPrivateKey(\n        '0x107be946709e41b7895eea9f2dacf998a0a9124acbb786f0fd1a826101581a07', // privateKey\n        {\n            iv: '02aeac54cb45283b427bd1a5028552c1',\n            ephemPublicKey: '044acf39ed83c304f19f41ea66615d7a6c0068d5fc48ee181f2fb1091...',\n            ciphertext: '5fbbcc1a44ee19f7499dbc39cfc4ce96',\n            mac: '96490b293763f49a371d3a2040a2d2cb57f246ee88958009fe3c7ef2a38264a1'\n        } // encrypted-data\n    );\n    // 'foobar'\n```\n\n### cipher.stringify()\n\nTransforms the object with the encrypted data into a smaller string-representation.\n\n```javascript\nconst str = EthCrypto.cipher.stringify({\n    iv: '02aeac54cb45283b427bd1a5028552c1',\n    ephemPublicKey: '044acf39ed83c304f19f41ea66615d7a6c0068d5fc48ee181f2fb1091...',\n    ciphertext: '5fbbcc1a44ee19f7499dbc39cfc4ce96',\n    mac: '96490b293763f49a371d3a2040a2d2cb57f246ee88958009fe3c7ef2a38264a1'\n});\n// > '59ab06532fc965b0107977f43e69e5a4038db32099dab281c8f5aece2852...'\n```\n\n### cipher.parse()\n\nParses the string-representation back into the encrypted object.\n\n```javascript\nconst str = EthCrypto.cipher.parse('59ab06532fc965b0107977f43e69e5a4038db32099dab281c8f5aece2852...');\n/* >  {\n        iv: '02aeac54cb45283b427bd1a5028552c1',\n        ephemPublicKey: '044acf39ed83c304f19f41ea66615d7a6c0068d5fc48ee181f2fb1091...',\n        ciphertext: '5fbbcc1a44ee19f7499dbc39cfc4ce96',\n        mac: '96490b293763f49a371d3a2040a2d2cb57f246ee88958009fe3c7ef2a38264a1'\n    } */\n```\n\n### signTransaction()\n\nSigns a raw transaction with the privateKey. Returns a serialized tx which can be submitted to the node.\n\n```javascript\nconst identity = EthCrypto.createIdentity();\nconst rawTx = {\n    from: identity.address,\n    to: '0x86Fa049857E0209aa7D9e616F7eb3b3B78ECfdb0',\n    value: new BN('1000000000000000000'),\n    gasPrice: 5000000000,\n    nonce: 0,\n    gasLimit: 21000\n};\nconst signedTx = EthCrypto.signTransaction(\n    rawTx,\n    identity.privateKey\n);\nconsole.log(signedTx);\n// > '071d3a2040a2d2cb...'\n\n// you can now send the tx to the node\nconst receipt = await web3.eth.sendSignedTransaction(signedTx);\n```\n\n### txDataByCompiled()\n\nCreates the data-string which must be submitted with an transaction to create a contract-instance.\n\n```javascript\nconst SolidityCli = require('solidity-cli');\n\n// create compiled solidity-code\nconst compiled = await SolidityCli.compileCode(\n    'contract ExampleContract {...'\n)[':ExampleContract'];\n\nconst createCode = EthCrypto.txDataByCompiled(\n    compiled.interface, // abi\n    compiled.bytecode, // bytecode\n    [identity.address] // constructor-arguments\n);\n\n// now you can submit this to the blockchain\nconst serializedTx = EthCrypto.signTransaction(\n    {\n        from: identity.address,\n        nonce: 0,\n        gasLimit: 5000000,\n        gasPrice: 5000000000,\n        data: createCode\n    },\n    identity.privateKey\n);\nconst receipt = await web3.eth.sendSignedTransaction(serializedTx);\n```\n\n### calculateContractAddress()\nCalculates the address for the contract from the senders address and the nonce, without deploying it to the blockchain.\n\n```javascript\n// pre-calculate address\nconst calculatedAddress = EthCrypto.calculateContractAddress(\n    account.address, // address of the sender\n    3 // nonce with which the contract will be deployed\n);\n\nconst rawTx = {\n    from: account.address,\n    gasPrice: parseInt(gasPrice),\n    nonce: 3,\n    data: compiled.code\n};\nconst receipt = await state.web3.eth.sendTransaction(rawTx);\n\nconsole.log(receipt.contractAddress === calculatedAddress);\n// > true\n```\n\n### hex compress/decompress\n\n\"Compress\" or \"decompress\" a hex-string to make it smaller. You can either compress to utf16 which reduces the size to about 1/4, or to base64 which reduces the size to about 4/5. This is not a real compression, it just make your string smaller when you have to store it in utf-16 anyways.\n\n```javascript\nconst hexString = '0x107be946709e41b7895eea9f2dacf998a0a9124acbb786f0fd1a826101581a07'; // 66 chars\n\nconst utf16 = EthCrypto.hex.compress(hexString); // compress to utf16\n// > 'ၻ炞䆷襞ⶬ輦ꂩቊ쮷蛰ﴚ艡Řᨇ' // 16 chars\n\nconst base64 = EthCrypto.hex.compress(hexString, true); // compress to base64\n// > 'EHvpRnCeQbeJXuqfLaz5mKCpEkrLt4bw/RqCYQFYGgc=' // 44 chars\n\nEthCrypto.hex.decompress(utf16); // decompress from utf16\n// > '0x107be946709e41b7895eea9f2d...'\n\nEthCrypto.hex.decompress(base64, true); // decompress from base64\n// > '0x107be946709e41b7895eea9f2d...'\n\n```\n","readmeFilename":"README.md"}