mirror of
https://github.com/cupcakearmy/cryptgeon.git
synced 2024-11-01 04:44:16 +01:00
21 lines
541 B
TypeScript
21 lines
541 B
TypeScript
import { createHash } from 'node:crypto'
|
|
import { cp, readFile } from 'node:fs/promises'
|
|
|
|
export const Files = {
|
|
PDF: 'test/assets/AES.pdf',
|
|
Image: 'test/assets/image.jpg',
|
|
Zip: 'test/assets/Pigeons.zip',
|
|
}
|
|
|
|
export async function getFileChecksum(file: string) {
|
|
const buffer = await readFile(file)
|
|
const hash = createHash('sha3-256').update(buffer).digest('hex')
|
|
return hash
|
|
}
|
|
|
|
export async function tmpFile(file: string) {
|
|
const name = `./tmp/${Math.random().toString(36).substring(7)}`
|
|
await cp(file, name)
|
|
return name
|
|
}
|