Skip to content

Commit bccc4ed

Browse files
committed
refactor: replace deprecated code
1 parent 6846c1d commit bccc4ed

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/lib/getHashDijest.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Big from 'big.js';
2-
import { createHash } from 'crypto';
2+
import { createHash, type BinaryToTextEncoding } from 'crypto';
33

44
const baseEncodeTables = {
55
26: 'abcdefghijklmnopqrstuvwxyz',
@@ -72,13 +72,13 @@ const getHashDigest = (
7272
digestType === 'base62' ||
7373
digestType === 'base64'
7474
) {
75-
return encodeBufferToBase(hash.digest(), parseInt(digestType.substr(4), 10)).substr(
75+
return encodeBufferToBase(hash.digest(), parseInt(digestType.substring(4), 10)).substring(
7676
0,
7777
maxLength
7878
);
7979
}
80-
const encoding = (digestType as 'latin1') || 'hex';
81-
return hash.digest(encoding).substr(0, maxLength);
80+
const encoding = (digestType as BinaryToTextEncoding) || 'hex';
81+
return hash.digest(encoding).substring(0, maxLength);
8282
};
8383

8484
export default getHashDigest;

0 commit comments

Comments
 (0)