UNPKG

@ksen/crypto-ts

Version:

A cryptography algorithms library compatible with ES6 and TypeScript

30 lines (24 loc) 507 B
import { WordArray, } from './core'; import { ZeroPadding, } from './pad-zeropadding'; /** * ISO/IEC 9797-1 Padding Method 2. */ export const Iso97971 = { pad(data, blockSize) { // Add 0x80 byte data.concat(WordArray.create([0x80000000], 1)); // Zero pad the rest ZeroPadding.pad(data, blockSize); }, unpad(data) { const _data = data; // Remove zero padding ZeroPadding.unpad(_data); // Remove one more byte -- the 0x80 byte _data.sigBytes -= 1; }, };