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

ts-pinblock

v0.1.3

Published

pinblock

Downloads

1

Readme

pinblock 算法 NodeJS 实现

pinblock 的 NodeJS 实现,支持 DES/3DES 算法SM4 算法

注意事项:

  1. pin 的长度是 4-12 位的纯数字
  2. DES/3DES 算法和 SM4 算法的算法区别在于前者返回的 pin 是 8 个字节,后者返回 16 个字节,按需入参。

使用方法:

DES/3DES 算法

import {pinblock} from 'ts-pinblock';

const pin = '123456'; // pin的长度是4-12位。

//——ANSI X9.8 格式(不带主账号信息)
const pb = pinblock(pin);

//——ANSIX9.8 格式(带主账号信息)
const pan = '123456789012345678';
const pb = pinblock(pin, pan);

SM4 算法

import {pinblock} from 'ts-pinblock';

const pin = '123456'; // pin的长度是4-12位。

//——ANSI X9.8 格式(不带主账号信息)
const pb = pinblock(pin, '', 16);

//——ANSIX9.8 格式(带主账号信息)
const pan = '123456789012345678';
const res = pinblock(pin, pan, 16);

API

pinblock

获取 pinblock。

入参:

  • pin 必填项目,pin 码,支持 4-12 位纯数字字符串
  • pan 非必填,一般是用户的卡号,默认值为空字符串
  • pbl 非必填,入参是 8 或者 16 的纯数字,默认值 8

返回: 如果出错,返回值为 null。 正常返回 Uint8Array(8)或者 Uint8Array(16)

arr2hex

把 Uint8Array 类型的数据转换为 16 进制的字符串数组.

import {pinblock, arr2hex} from 'ts-pinblock';
const pin = '123456';

const pb = pinblock(pin);
console.log(arr2hex(pb).join(' ')); // 0x06 0x12 0x34 0x56 0xFF 0xFF 0xFF 0xFF