npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

iso8583-es

v1.0.2

Published

A ISO8583 protocol sdk with ES6 and TypeScript

Downloads

9

Readme

iso8583-es

A pure, high-performance library with ES6 and typescript, used to encode and decode the ISO8583 protocol

Note: Please use latest version

Usage

npm i --save iso8583-es
编码
import i8es from 'iso8583-es'
const {
  HEX, FieldDefinition, ISOBody, ISOField, ISOInputStream, ISOOutputStream
} = i8es

const fields = ISOField.makeFields(FieldDefinition, true); // 全局初始化一次

const body = new ISOBody(fields);
body.setType("0800"); // 签到
body.setField(11, "000456"); // 流水号
body.setField(41, "12345678"); // 终端编号
body.setField(42, "123456789012345"); // 商户编号
body.setField(60, "00" + "123456" + "003"); // 消息类型码00+批次号+双倍长密钥算法
body.setField(63, "03"); // 操作员号
const ios = new ISOOutputStream();
body.appendTo(ios);
console.log("编码结果")
console.log(HEX.byte2Hex(ios.toByteArray()))
console.log(body.toString())

得到结果

编码结果
08000020000000C000120004563132333435363738313233343536373839303132333435001100123456003000023033
TYPE:0800
11:000456//受卡方系统跟踪号
41:12345678//受卡机终端标识码
42:123456789012345//受卡方标识码
60:00123456003//自定义域
63:03//自定义域
解码
const ds = HEX.hex2Bytes("0200202004C020C0981131000000015402100006376227594325183289D1703101000000180000003031303031373934383730343531303037383030303236313536C411E6435383EB8526000000000000000013010000010005003030303030303030");
const iis = new ISOInputStream(ds);
const resp = new ISOBody(fields);
resp.decode(iis); // 解码
console.log(resp.toString());

得到结果

TYPE:0200
3:310000//交易处理码
11:000154//受卡方系统跟踪号
22:021//服务点输入方式码
25:00//服务点条件码
26:06//服务点PIN获取码
35:62****00//2磁道数据
41:01001794//受卡机终端标识码
42:870451007800026//受卡方标识码
49:156//交易货币代码
52:C4****85//个人标识码数据
53:26****00//安全控制信息
60:0100000100050//自定义域
64:3030303030303030//MAC

或者单独导入

import ISOUtil from "iso8583-es/lib/core/ISOUtil.js";
import ISOBody from "iso8583-es/lib/core/ISOBody.js";