{"id":13606895,"url":"https://github.com/deepal/node-dukpt","last_synced_at":"2025-10-15T14:31:11.973Z","repository":{"id":38027367,"uuid":"77236054","full_name":"deepal/node-dukpt","owner":"deepal","description":"Node JS Library for Derived Unique Key Per Transaction (DUKPT) Encryption 💳🔑🛡","archived":false,"fork":false,"pushed_at":"2023-01-07T04:10:35.000Z","size":602,"stargazers_count":28,"open_issues_count":4,"forks_count":22,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-20T18:27:40.073Z","etag":null,"topics":["aes","decryption","dukpt","dukpt-encryption","encryption","javascript","node-dukpt","nodejs","payments","security"],"latest_commit_sha":null,"homepage":"https://jsblog.insiderattack.net/dukpt-derived-unique-key-per-transaction-with-node-js-72a6642ce89","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deepal.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-23T16:02:30.000Z","updated_at":"2025-07-04T02:07:12.000Z","dependencies_parsed_at":"2023-02-06T11:16:08.181Z","dependency_job_id":null,"html_url":"https://github.com/deepal/node-dukpt","commit_stats":null,"previous_names":["dpjayasekara/node-dukpt"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/deepal/node-dukpt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepal%2Fnode-dukpt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepal%2Fnode-dukpt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepal%2Fnode-dukpt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepal%2Fnode-dukpt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deepal","download_url":"https://codeload.github.com/deepal/node-dukpt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepal%2Fnode-dukpt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279085451,"owners_count":26100017,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-15T02:00:07.814Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aes","decryption","dukpt","dukpt-encryption","encryption","javascript","node-dukpt","nodejs","payments","security"],"created_at":"2024-08-01T19:01:13.556Z","updated_at":"2025-10-15T14:31:11.617Z","avatar_url":"https://github.com/deepal.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# node-dukpt\n\n[![npm version](https://badge.fury.io/js/dukpt.svg)](https://badge.fury.io/js/dukpt) ![alt downloads](https://img.shields.io/npm/dm/dukpt.svg?style=flat-square)\n\n## Derived Unique Key Per Transaction (DUKPT) Encryption with NodeJS\n\nThis the NodeJS implementation of DUKPT based on the vanilla javascript implementation of **IDTech** DUKPT encryption/decryption. This module provides Dukpt encryption using either 3DES or AES schemes.\n\n\u003e Please note that AES encryption/decryption is currently only supported with NodeJS versions 6.x.x and above due to few limitations which will be addressed soon in a next release.\n\nDon't hesitate to report any bugs in the [Github Repository!](https://github.com/dpjayasekara/node-dukpt). Many thanks to @jamiesoncj for providing resources.\n\n### Prerequisites\n\n* Node v12.0.0 or above\n\n### Installing\n\n```\nnpm install dukpt --save\n```\n### Using DUKPT\n\nInitialize DUKPT by providing BDK and KSN:\n\n```\nconst Dukpt = require('dukpt');\n\nconst encryptionBDK = '0123456789ABCDEFFEDCBA9876543210';\nconst ksn = 'FFFF9876543210E00008';\nconst keyMode = 'datakey'; // optional: defaults to 'datakey'\nconst plainTextCardData = '%B5452310551227189^DOE/JOHN      ^08043210000000725000000?';\n\nconst dukpt = new Dukpt(encryptionBDK, ksn);\n```\nAfter initializing, you can use `dukptEncrypt` and `dukptDecrypt` methods to encrypt/decrypt data using DUKPT. \n\n#### Encrypting `ascii` data\n\nUsing 3DES,\n\n```\nconst options = {\n\tinputEncoding: 'ascii', \n\toutputEncoding: 'hex',\n\tencryptionMode: '3DES'\n};\nconst encryptedCardData3Des = dukpt.dukptEncrypt(plainTextCardData, options);\n```\nor with AES,\n\n```\nconst options = {\n\tinputEncoding: 'ascii', \n\toutputEncoding: 'hex',\n\tencryptionMode: 'AES'\n};\nconst encryptedCardDataAes = dukpt.dukptEncrypt(plainTextCardData, options);\n```\n\n#### Encrypting `hex` data\n\nUsing 3DES,\n\n```\nconst options = {\n\tinputEncoding: 'hex',\n\toutputEncoding: 'hex',\n\tencryptionMode: '3DES'\n};\nconst encryptedCardData3Des = dukpt.dukptEncrypt(plainTextCardData, options);\n```\nor using AES,\n\n```\nconst options = {\n\tinputEncoding: 'hex',\n\toutputEncoding: 'hex',\n\tencryptionMode: 'AES'\n};\nconst encryptedCardDataAes = dukpt.dukptEncrypt(plainTextCardData, options);\n```\n\n#### Decrypting data with `ascii` output encoding\n\n```\nconst options = {\n\toutputEncoding: 'ascii',\n\tdecryptionMode: '3DES',\n\ttrimOutput: true\n};\n\nconst decryptedCardData = dukpt.dukptDecrypt(encryptedCardData, options);\n```\n#### Decrypting data with `hex` output encoding\n\n```\nconst options = {\n\toutputEncoding: 'hex',\n\tdecryptionMode: '3DES',\n\ttrimOutput: true\n};\n\nconst decryptedCardData = dukpt.dukptDecrypt(encryptedCardData, options);\n```\n\n## API\n\n### constructor Dukpt(bdk, ksn, [keyMode])\n\n#### bdk\n\nBase derivation key (BDK) for initialization\n\n#### ksn\n\nKey serial number (KSN) for initialization\n\n\u003e _See [here](https://en.wikipedia.org/wiki/Derived_unique_key_per_transaction) for more information on BDK and KSN_\n\n#### keyMode\ndefault: 'datakey'\n\nKey mode for deriving session key from initial pin encryption key (IPEK). Possible values are:\n\n- `datakey` (default)\n- `pinkey`\n- `mackey`\n\n#### Dukpt.prototype.dukptEncrypt(plainTextCardData, options) and Dukpt.prototype.dukptDecrypt(encryptedCardData, options)\n\n#### options\n\nYou can use options object to provide additional options for the DUKPT encryption/decryption. This object is **optional** and, if you don't provide it, encryption/decryption will use the default values shipped with it. \n\nFollowing listed are the available options.\n\nOption | Possible Values | Default Value | Description\n------------ | ------- | ------------- | --------------\n`outputEncoding` | `ascii`, `hex` | For encryption `hex`, for decryption `ascii` | Specify output encoding of encryption/decryption\n`inputEncoding` | `ascii`, `hex` | For encryption `ascii`, for decryption `hex` | Specify encoding of the input data for encryption/decryption\n`trimOutput` (for decryption only) | `true`, `false` | `false` | Specify whether to strip out null characters from the decrypted output\n`encryptionMode` (for encryption only) | `3DES`/`AES` | `3DES`/`AES` | Specify encryption scheme for dukpt\n`decryptionMode` (for decryption only) | `3DES`/`AES` | `3DES`/`AES` | Specify decryption scheme for dukpt\n\n### Tests\nTests can be run using gulp as follows:\n\n```\nnpm run test\n```\n\n#### Roadmap\n\n- [x] Support for DUKPT Encryption/Decryption with 3DES\n- [x] Support for DUKPT Encryption/Decryption with AES\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepal%2Fnode-dukpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeepal%2Fnode-dukpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepal%2Fnode-dukpt/lists"}