In Node.js , cannot read property 'length' of undefined -


i have make cryptogram using node.js please ..!!! (and make cryptogram key ? ? ) have tried. . :)

function encrypt(data,j) {     for(var = 0, length = data.length; i<length; i++) {          j = data.charcodeat(i);         //console.log(j);         string.fromcharcode(j);         process.stdout.write(j);     }     return data; }  function decrypt(data) {     return data; }  process.stdin.resume(); process.stdin.setencoding('utf-8');  process.stdout.write('input (암호화할 문장을 입력) : ' );  process.stdin.on('data',function(data,j) {     //data = data.trim();     process.stdout.write('평문(your input) :' + data);     process.stdout.write('암호문(encrypt) :');     encrypt(j);     process.stdout.write('복호문(decrypt) :');      process.exit();     }); 

process.stdin readable stream. callback accepts single parameter (see doc example). safe, i'd call encrypt() on on stdin end event. call concatenation of data.

process.stdin.on('data',function(data) {     process.stdout.write('평문(your input) :' + data);     process.stdout.write('암호문(encrypt) :');     encrypt(data);     process.stdout.write('복호문(decrypt) :');     process.exit(); }); 

if me, gather data stdin string (it can string or buffer), , process on stream's end event:

var input = ''; process.stdin.on('data',function(data) {     process.stdout.write('평문(your input) :' + data);     input+=data; });  process.stdin.on('end', function(){     process.stdout.write('암호문(encrypt) :');     encrypt(input);     process.stdout.write('복호문(decrypt) :');     process.exit(); }); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -