'Error : Digest method not supported while using winston.transports.DailyRotate

Environment :

OS : SUSE Linux Enterprise Server 15 SP2 Node: 14.16.0 Express: 4.17.1, winston: 3.2.1, winston-daily-rotate-file: 4.4.2

I am using following code :

 var transport = new (winston.transports.DailyRotateFile)({
        filename: 'log/server-%DATE%.log',
        datePattern: 'YYYY-MM-DD-HH',
        maxSize: '100m', //100MB
        zippedArchive: true,
        maxFiles: '10',
        frequency: '24h'
    });

and getting error from crypto submodule of nodejs as "Digest method not supported"

Below is actual line which was throwing error from File "FileStreamRotator.js" under node_modules : crypto.createHash('md5').update(logfile + "LOG_FILE" + time).digest("hex")

Can someone please help to identify the issue here and probable solution?

Issue raised in winston-daily-rotate-file (This has been closed as actual issue is in file-stream-rotator and dependent crypto submodule of nodejs ) : https://github.com/winstonjs/winston-daily-rotate-file/issues/340

Raised the question in file-stream-rotator repo : https://github.com/rogerc/file-stream-rotator/issues/90



Solution 1:[1]

Check out this link.

make sure that the string you are using for the createHash algorithm is actually the same as a string available from openssl on your machine.

for example "sha265" will throw this error, but "SHA265" will not

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jay Day Zee