Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | 1x 7x 1x 4x 3x 3x 1x 1x 1x 1x 1x 1x 1x 32x 32x 32x 1x 1x 1x 13x 6x 7x | import {ASN1MessageFormat} from './interfaces/ASN1MessageFormat';
import {Props} from './interfaces/Props';
export const sanitize = (str: string) =>
str
.replace(/#.*/g, '')
.replace(/ /g, '')
.replace(/\r?\n|\r/g, '');
export const getArrayBufferFromStr = (
inputMsg: string,
format: ASN1MessageFormat
): ArrayBuffer => {
if (format === 'hex') {
const buf = Buffer.from(sanitize(inputMsg), 'hex');
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
}
Eif (format === 'base64') {
const buf = Buffer.from(sanitize(inputMsg), 'base64');
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
}
throw new Error('format not yet implemented: ' + format);
};
// 0110011001010 -> 0_1100_1100_1010
export function formatBitString(value: string): string {
const bits = value.split('');
let result = '';
for (let i = 0; i < bits.length; i++) {
const bit = bits[bits.length - 1 - i];
const sep = i === 0 || i % 4 ? '' : '_';
result = bit + sep + result;
}
return result;
}
export function cloneAlpha(obj: Props): Props {
const x: Props = {};
for (const key of Object.keys(obj).sort()) {
if (obj[key] instanceof Array) {
x[key] = (obj[key] as Props[]).map(k => cloneAlpha(k));
} else if (obj[key] instanceof Object) {
x[key] = cloneAlpha(obj[key] as Props);
} else {
x[key] = obj[key];
}
}
return x;
}
export function padHexString(hex: string) {
if (hex.length % 2) {
return '0' + hex;
}
return hex;
}
|