mirror of
https://github.com/IT4Change/gradido.git
synced 2026-03-01 12:44:43 +00:00
16 lines
507 B
TypeScript
16 lines
507 B
TypeScript
import { crypto_generichash_batch, crypto_generichash_KEYBYTES } from 'sodium-native'
|
|
|
|
export function bytesToMbyte(bytes: number): string {
|
|
return (bytes / 1024 / 1024).toFixed(4)
|
|
}
|
|
|
|
export function bytesToKbyte(bytes: number): string {
|
|
return (bytes / 1024).toFixed(0)
|
|
}
|
|
|
|
export function calculateOneHashStep(hash: Buffer, data: Buffer): Buffer<ArrayBuffer> {
|
|
const outputHash = Buffer.alloc(crypto_generichash_KEYBYTES, 0)
|
|
crypto_generichash_batch(outputHash, [hash, data])
|
|
return outputHash
|
|
}
|