INNER CODE UNIT · TypeScript

b64ToBuffer

KishanBagaria/padding-oracle-attacker · src/cli.ts:115

const b64ToBuffer = (str: string) => Buffer.from(str.replace(/\s+/g, ''), 'base64')
function strToBuffer(input: string, fromPlain: boolean = true) {
  if (input.startsWith('hex:')) return hexToBuffer(input.slice('hex:'.length))
  if (input.startsWith('base64:')) return b64ToBuffer(input.slice('base64:'.length))
  if (input.startsWith('b64:')) return b64ToBuffer(input.slice('b64:'.length))
  if (input.startsWith('utf8:')) return Buffer.from(input.slice('utf8:'.length), 'utf8')
  if (fromPlain) return Buffer.from(input, 'utf8')
  throw Error('Input string should start with `hex:` or `base64:`/`b64:`')
}
async function main() {
  const [operation, url] = argv._
  const [,, thirdArg, fourthArg, paddingError] = argv._ as string[] | number[]
  if (version) {
    console.log(PKG_NAME, 'v' + PKG_VERSION)
    return
  }
  const isEncrypt = operation === 'encrypt'
  const isDecrypt = operation === 'decrypt'

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…