File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 7575 < script >
7676 function encrypt ( ) {
7777 const text = document . querySelector ( '#decrypted' ) ?. value ;
78+
7879 if ( ! text ) {
7980 alert ( 'Please, enter the encryption text!' ) ;
8081 return ;
8182 }
8283
83- const result = document . querySelector ( '#encrypted' ) ;
8484 let cursor = 0 ;
8585 let output = '' ;
86-
86+ const result = document . querySelector ( '#encrypted' ) ;
8787 const key = prompt ( 'Enter the encryption key:' , '' ) ;
88+
8889 if ( result && key ) {
8990 for ( let i = 0 ; i < text . length ; i ++ ) {
9091 if ( cursor > ( key . length - 1 ) ) cursor = 0 ;
100101 }
101102 function decrypt ( ) {
102103 const text = document . querySelector ( '#encrypted' ) ?. value . split ( ' ' ) ;
104+
103105 if ( ! text ) {
104106 alert ( 'Please, enter the encrypted text!' ) ;
105107 return ;
106108 }
107109
108- const result = document . querySelector ( '#decrypted' ) ;
109110 let cursor = 0 ;
110111 let output = '' ;
112+ const result = document . querySelector ( '#decrypted' ) ;
111113 const key = prompt ( 'Enter the decryption key:' , '' ) ;
114+
112115 if ( result && key ) {
113116 for ( let i = 0 ; i < text . length ; i ++ ) {
114117 if ( cursor > ( key . length - 1 ) ) { cursor = 0 ; }
You can’t perform that action at this time.
0 commit comments