Stream Generated QR Codes for data transmission
This project is made possible by all the sponsors supporting my work
You can join them at my sponsors profile:
import {
createGeneraterANSI,
createGeneraterUnicode,
createGeneraterUnicodeCompact,
createGeneraterSVG,
createGeneraterQRCodeArray,
} from '@qifi/generate'
const generaterSvg = createGeneraterSVG(new Uint8Array(file.buffer))
const generaterANSI = createGeneraterANSI(new Uint8Array(file.buffer), {
// Size of each data slice
sliceSize: 250,
// Error correction level
ecc: 'L',
// Border width
border: 2,
})
// display QR Code in terminal
for (const blockQRCode of generaterANSI.fountain()) {
console.log(blockQRCode)
}
If you want to transfer the metadata of the file:
import {
appendFileHeaderMetaToBuffer,
readFileHeaderMetaFromBuffer,
} from '@qifi/generate'
const data = new Uint8Array(file.buffer)
const meta = {
filename: file.name,
contentType: file.type,
}
const merged = appendFileHeaderMetaToBuffer(data, meta)
const generater = createGeneraterUnicode(merged)
// Send blocks to the receiver
for (const block of generater.fountain()) {
// display QR Code in terminal
console.log(blockQRCode)
}
and you can use appendMetaToBuffer
and readMetaFromBuffer
to add and read custom metadata.