@@ -236,17 +236,19 @@ function Cipheriv(cipher, key, iv, options) {
236
236
createCipherWithIV . call ( this , cipher , key , options , true , iv ) ;
237
237
}
238
238
239
- inherits ( Cipheriv , LazyTransform ) ;
240
-
241
- Cipheriv . prototype . _transform = Cipher . prototype . _transform ;
242
- Cipheriv . prototype . _flush = Cipher . prototype . _flush ;
243
- Cipheriv . prototype . update = Cipher . prototype . update ;
244
- Cipheriv . prototype . final = Cipher . prototype . final ;
245
- Cipheriv . prototype . setAutoPadding = Cipher . prototype . setAutoPadding ;
246
- Cipheriv . prototype . getAuthTag = Cipher . prototype . getAuthTag ;
247
- Cipheriv . prototype . setAuthTag = Cipher . prototype . setAuthTag ;
248
- Cipheriv . prototype . setAAD = Cipher . prototype . setAAD ;
239
+ function addCipherPrototypeFunctions ( constructor ) {
240
+ constructor . prototype . _transform = Cipher . prototype . _transform ;
241
+ constructor . prototype . _flush = Cipher . prototype . _flush ;
242
+ constructor . prototype . update = Cipher . prototype . update ;
243
+ constructor . prototype . final = Cipher . prototype . final ;
244
+ constructor . prototype . setAutoPadding = Cipher . prototype . setAutoPadding ;
245
+ constructor . prototype . getAuthTag = Cipher . prototype . getAuthTag ;
246
+ constructor . prototype . setAuthTag = Cipher . prototype . setAuthTag ;
247
+ constructor . prototype . setAAD = Cipher . prototype . setAAD ;
248
+ }
249
249
250
+ inherits ( Cipheriv , LazyTransform ) ;
251
+ addCipherPrototypeFunctions ( Cipheriv ) ;
250
252
251
253
function Decipher ( cipher , password , options ) {
252
254
if ( ! ( this instanceof Decipher ) )
@@ -256,15 +258,7 @@ function Decipher(cipher, password, options) {
256
258
}
257
259
258
260
inherits ( Decipher , LazyTransform ) ;
259
-
260
- Decipher . prototype . _transform = Cipher . prototype . _transform ;
261
- Decipher . prototype . _flush = Cipher . prototype . _flush ;
262
- Decipher . prototype . update = Cipher . prototype . update ;
263
- Decipher . prototype . final = Cipher . prototype . final ;
264
- Decipher . prototype . setAutoPadding = Cipher . prototype . setAutoPadding ;
265
- Decipher . prototype . getAuthTag = Cipher . prototype . getAuthTag ;
266
- Decipher . prototype . setAuthTag = Cipher . prototype . setAuthTag ;
267
- Decipher . prototype . setAAD = Cipher . prototype . setAAD ;
261
+ addCipherPrototypeFunctions ( Decipher ) ;
268
262
269
263
270
264
function Decipheriv ( cipher , key , iv , options ) {
@@ -275,16 +269,7 @@ function Decipheriv(cipher, key, iv, options) {
275
269
}
276
270
277
271
inherits ( Decipheriv , LazyTransform ) ;
278
-
279
- Decipheriv . prototype . _transform = Cipher . prototype . _transform ;
280
- Decipheriv . prototype . _flush = Cipher . prototype . _flush ;
281
- Decipheriv . prototype . update = Cipher . prototype . update ;
282
- Decipheriv . prototype . final = Cipher . prototype . final ;
283
- Decipheriv . prototype . setAutoPadding = Cipher . prototype . setAutoPadding ;
284
- Decipheriv . prototype . getAuthTag = Cipher . prototype . getAuthTag ;
285
- Decipheriv . prototype . setAuthTag = Cipher . prototype . setAuthTag ;
286
- Decipheriv . prototype . setAAD = Cipher . prototype . setAAD ;
287
-
272
+ addCipherPrototypeFunctions ( Decipheriv ) ;
288
273
289
274
module . exports = {
290
275
Cipher,
0 commit comments