Skip to content

Commit

Permalink
replace md5 util
Browse files Browse the repository at this point in the history
  • Loading branch information
vpalmisano committed May 15, 2024
1 parent 3c66ddb commit 88053ec
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/media.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { existsSync, promises } from 'fs'

import { logger, md5, runShellCommand } from './utils'
import { logger, runShellCommand, sha256 } from './utils'

const log = logger('webrtcperf:media')

Expand Down Expand Up @@ -67,7 +67,7 @@ export async function prepareFakeMedia({
}

await promises.mkdir(videoCachePath, { recursive: true })
const name = md5(videoPath)
const name = sha256(videoPath)

const destVideoPath = `${videoCachePath}/${name}_${videoWidth}x${videoHeight}_${videoFramerate}fps.${videoFormat}`
const destAudioPath = `${videoCachePath}/${name}.wav`
Expand Down
4 changes: 2 additions & 2 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import {
getSystemStats,
hideAuth,
logger,
md5,
PeerConnectionExternal,
PeerConnectionExternalMethod,
resolveIP,
resolvePackagePath,
sha256,
sleep,
} from './utils'

Expand Down Expand Up @@ -1227,7 +1227,7 @@ window.SERVER_USE_HTTPS = ${this.serverUseHttps};
await page.exposeFunction(
'uploadFileFromUrl',
async (fileUrl: string, selector: string) => {
const filename = md5(fileUrl) + '.' + fileUrl.split('.').slice(-1)[0]
const filename = sha256(fileUrl) + '.' + fileUrl.split('.').slice(-1)[0]
const filePath = path.join(
os.homedir(),
'.webrtcperf/uploads',
Expand Down
6 changes: 3 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ export function resolvePackagePath(relativePath: string): string {
}

/**
* Calculates the md5 sum.
* Calculates the sha256 sum.
* @param data The string input
*/
export function md5(data: string): string {
return createHash('md5').update(data).digest('hex')
export function sha256(data: string): string {
return createHash('sha256').update(data).digest('hex')
}

const ProcessStatsCache = new NodeCache({ stdTTL: 5, checkperiod: 10 })
Expand Down

0 comments on commit 88053ec

Please sign in to comment.