/** * @module encryption respec * * we gotta test our encryption ibgibs */ // import { cwd, chdir, } from 'node:process'; // import { statSync } from 'node:fs'; // import { mkdir, } from 'node:fs/promises'; // import { ChildProcess, exec, ExecException } from 'node:child_process'; import * as pathUtils from 'path'; import { firstOfAll, firstOfEach, ifWe, ifWeMight, iReckon, lastOfAll, lastOfEach, respecfully, respecfullyDear } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs'; const maam = `[${import.meta.url}]`, sir = maam; import { extractErrorMsg, delay, getSaferSubstring, getTimestampInTicks, getUUID, pretty, HashAlgorithm, clone, getTimestamp, } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs'; import { GLOBAL_LOG_A_LOT } from '../../core-constants.mjs'; import { EncryptionData_V1, EncryptionMethod } from './encrypt-types.mjs'; import { SaltStrategy } from '@ibgib/encrypt-gib/dist/types.mjs'; import { getEncryptionIb, parseEncryptionIb } from './encrypt-helper.mjs'; import { ENCRYPTION_ATOM } from './encrypt-constants.mjs'; /** * for verbose logging */ const logalot = GLOBAL_LOG_A_LOT; // change this when you want to turn off verbose logging const lcFile: string = `[${pathUtils.basename(import.meta.url)}]`; const atom = ENCRYPTION_ATOM; const recursionCount = 168; const hashAlgorithm: HashAlgorithm = 'SHA-256'; const saltPrependedPerHash = ''; const saltStrategy = SaltStrategy.prependPerHash; const initialRecursions = 1000; const recursionsPerHash = 2; const method: EncryptionMethod = EncryptionMethod.encrypt_gib; const salt_empty = ''; // const description = 'description yo'; const blockName = `encryption ib`; await respecfully(maam, blockName, async () => { const lc = `${lcFile}[${blockName}]`; debugger; const name = await getUUID(); const timestampDate = new Date(); const timestamp = getTimestamp(timestampDate); const timestampMs = timestampDate.getMilliseconds(); const data_valid: EncryptionData_V1 = { name, hashAlgorithm, initialRecursions: 1000, method, salt: salt_empty, description, encryptedDataDelimiter: undefined, recursionsPerHash, saltStrategy, n: 0, timestamp, timestampMs, blockMode: false, }; await ifWe(maam, `getEncryptionIb`, async () => { const data = data_valid; let ib = getEncryptionIb({ data }); iReckon(sir, ib.includes(name)).asTo('name').isGonnaBeTrue(); iReckon(sir, ib.includes(method)).asTo('method').isGonnaBeTrue(); }); await ifWe(maam, `parseEncryptionIb`, async () => { const data = data_valid; let ib = getEncryptionIb({ data }); let parsed = parseEncryptionIb({ ib }); iReckon(sir, parsed.atom).asTo('atom').isGonnaBe(atom); iReckon(sir, parsed.name).asTo('name').isGonnaBe(name); iReckon(sir, parsed.method).asTo('method').isGonnaBe(method); }); });