1- var test = require ( 'tape' )
1+ var Buffer = require ( 'safe-buffer' ) . Buffer
22var CipherBase = require ( './' )
3+
4+ var test = require ( 'tape' )
35var inherits = require ( 'inherits' )
46
57test ( 'basic version' , function ( t ) {
6- inherits ( Cipher , CipherBase )
78 function Cipher ( ) {
89 CipherBase . call ( this )
910 }
11+ inherits ( Cipher , CipherBase )
1012 Cipher . prototype . _update = function ( input ) {
1113 t . ok ( Buffer . isBuffer ( input ) )
1214 return input
@@ -17,16 +19,16 @@ test('basic version', function (t) {
1719 var cipher = new Cipher ( )
1820 var utf8 = 'abc123abcd'
1921 var update = cipher . update ( utf8 , 'utf8' , 'base64' ) + cipher . final ( 'base64' )
20- var string = ( new Buffer ( update , 'base64' ) ) . toString ( )
22+ var string = ( Buffer . from ( update , 'base64' ) ) . toString ( )
2123 t . equals ( utf8 , string )
2224 t . end ( )
2325} )
2426test ( 'hash mode' , function ( t ) {
25- inherits ( Cipher , CipherBase )
2627 function Cipher ( ) {
2728 CipherBase . call ( this , 'finalName' )
2829 this . _cache = [ ]
2930 }
31+ inherits ( Cipher , CipherBase )
3032 Cipher . prototype . _update = function ( input ) {
3133 t . ok ( Buffer . isBuffer ( input ) )
3234 this . _cache . push ( input )
@@ -37,17 +39,17 @@ test('hash mode', function (t) {
3739 var cipher = new Cipher ( )
3840 var utf8 = 'abc123abcd'
3941 var update = cipher . update ( utf8 , 'utf8' ) . finalName ( 'base64' )
40- var string = ( new Buffer ( update , 'base64' ) ) . toString ( )
42+ var string = ( Buffer . from ( update , 'base64' ) ) . toString ( )
4143
4244 t . equals ( utf8 , string )
4345 t . end ( )
4446} )
4547test ( 'hash mode as stream' , function ( t ) {
46- inherits ( Cipher , CipherBase )
4748 function Cipher ( ) {
4849 CipherBase . call ( this , 'finalName' )
4950 this . _cache = [ ]
5051 }
52+ inherits ( Cipher , CipherBase )
5153 Cipher . prototype . _update = function ( input ) {
5254 t . ok ( Buffer . isBuffer ( input ) )
5355 this . _cache . push ( input )
@@ -62,11 +64,12 @@ test('hash mode as stream', function (t) {
6264 var utf8 = 'abc123abcd'
6365 cipher . end ( utf8 , 'utf8' )
6466 var update = cipher . read ( ) . toString ( 'base64' )
65- var string = ( new Buffer ( update , 'base64' ) ) . toString ( )
67+ var string = ( Buffer . from ( update , 'base64' ) ) . toString ( )
6668
6769 t . equals ( utf8 , string )
6870 t . end ( )
6971} )
72+
7073test ( 'encodings' , function ( t ) {
7174 inherits ( Cipher , CipherBase )
7275 function Cipher ( ) {
0 commit comments