const test=require('node:test'),assert=require('node:assert/strict'),crypto=require('node:crypto'),fs=require('node:fs'); const hash=require('./web/file-hash.js'); test('upload MD5 matches RFC vectors and a multi-block file',()=>{ for(const text of ['', 'a', 'abc', 'message digest', 'abcdefghijklmnopqrstuvwxyz', '照片与语音', 'x'.repeat(4194304)]){ const bytes=Buffer.from(text);assert.equal(hash.md5(bytes),crypto.createHash('md5').update(bytes).digest('hex')); } }); test('browser hashes in 4 MiB slices rather than loading the entire video',async()=>{ const file=new Blob([Buffer.alloc(4194304,1),Buffer.from('tail')]);const values=await hash.blocks(file); assert.equal(values.length,2);assert.equal(values[1],crypto.createHash('md5').update('tail').digest('hex')); await assert.rejects(hash.blocks(file,()=>{},()=>false),/取消/); }); test('journals default to private and encode content before rendering',()=>{ const html=require('./test-support/ui-source')(),js=fs.readFileSync('web/journal.js','utf8'); assert.match(html,/