From 7d0de11ce28d5e025023af06545371a665e21b15 Mon Sep 17 00:00:00 2001 From: Tobias Speicher Date: Sun, 20 Mar 2022 06:34:56 +0100 Subject: [PATCH] refactor: replace deprecated String.prototype.substr() .substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated Signed-off-by: Tobias Speicher --- src/core.js | 2 +- test/rc4-test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core.js b/src/core.js index e1330e7..fe6f33d 100644 --- a/src/core.js +++ b/src/core.js @@ -418,7 +418,7 @@ var CryptoJS = CryptoJS || (function (Math, undefined) { // Convert var words = []; for (var i = 0; i < hexStrLength; i += 2) { - words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4); + words[i >>> 3] |= parseInt(hexStr.slice(i, i + 2), 16) << (24 - (i % 8) * 4); } return new WordArray.init(words, hexStrLength / 2); diff --git a/test/rc4-test.js b/test/rc4-test.js index 721b676..debaaa3 100644 --- a/test/rc4-test.js +++ b/test/rc4-test.js @@ -14,7 +14,7 @@ YUI.add('algo-rc4-test', function (Y) { testDrop: function () { Y.Assert.areEqual( - C.RC4.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0123456789abcdef')).ciphertext.toString().substr(16), + C.RC4.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0123456789abcdef')).ciphertext.toString().slice(16), C.RC4Drop.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('0123456789abcdef'), { drop: 2 }).ciphertext.toString() ); },