File tree Expand file tree Collapse file tree 3 files changed +13
-11
lines changed Expand file tree Collapse file tree 3 files changed +13
-11
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -5,12 +5,15 @@ const log = console.log,
55 pwd = process . argv [ 3 ] ;
66
77if ( process . argv . length !== 4 ) {
8- console . error ( '命令行格式 :cmd username password' ) ;
8+ console . error ( 'usage :cmd username password' ) ;
99 process . exit ( 1 ) ;
1010}
1111
1212log ( 'user name: %s\npassword: %s' , usr , pwd ) ;
1313
14- const buf = Buffer . from ( usr + ':' + pwd ) ;
14+ // method A
15+ log ( 'Base64:' , btoa ( usr + ':' + pwd ) ) ;
1516
17+ // method B
18+ const buf = Buffer . from ( usr + ':' + pwd ) ;
1619log ( 'Base64:' , buf . toString ( 'Base64' ) ) ;
Original file line number Diff line number Diff line change 11#!/usr/bin/env node
22
33if ( process . argv . length !== 3 ) {
4- console . error ( '命令行格式 :cmd base64_string' ) ;
4+ console . error ( 'usage :cmd base64_string' ) ;
55 process . exit ( 1 ) ;
66}
77
8+ // method A
9+ const buf = atob ( process . argv [ 2 ] ) ;
10+ const info = buf . split ( ':' ) ;
11+
12+ // method B
13+ /*
814const buf = Buffer.from(process.argv[2], 'base64');
915const info = buf.toString('utf8').split(':');
16+ */
1017
1118if ( info . length !== 2 ) {
1219 console . error ( '信息有误!' ) ;
You can’t perform that action at this time.
0 commit comments