mirror of
https://github.com/chrononeko/chronocat.git
synced 2024-11-21 22:58:10 +00:00
chore: add dti script
This commit is contained in:
parent
cdce410c8b
commit
87450cb656
23
scripts/dti.cts
Normal file
23
scripts/dti.cts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import type { Buffer } from 'node:buffer'
|
||||||
|
import { verify } from 'node:crypto'
|
||||||
|
import { readFile } from 'node:fs/promises'
|
||||||
|
import { resolve } from 'node:path'
|
||||||
|
import { argv } from 'node:process'
|
||||||
|
|
||||||
|
const checkScript = (key: Buffer, rawFile: Buffer) =>
|
||||||
|
new Promise<Buffer>((res, rej) => {
|
||||||
|
const partSig = rawFile.subarray(0, 1024)
|
||||||
|
const partData = rawFile.subarray(1024)
|
||||||
|
|
||||||
|
verify('sha256', partData, key, partSig, (e, r) =>
|
||||||
|
e ? rej(e) : r ? res(partData) : rej(new Error('Check failed.')),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
void (async () => {
|
||||||
|
const key = await readFile(
|
||||||
|
resolve(__dirname, '../packages/docs/static/ti.pub'),
|
||||||
|
)
|
||||||
|
const rawFile = await readFile(argv[2]!)
|
||||||
|
await checkScript(key, rawFile)
|
||||||
|
})()
|
Loading…
Reference in New Issue
Block a user