c# 4.0 - how to create secret key automatically after 5 minute in C# windows application -
i create 1 function in class file:
public string createprivacykey(string s3) { prky = convert.tostring(s3); return prky; }
and function call in windows form on button click event:
private void button1_click(object sender, eventargs e) { string cleartext = textbox2.text.trim(); string ciphertext=class1.encrypt(cleartext,true); // txtdecryptedtext.visible = false; //label3.visible = false; textbox2.text = ciphertext; label3.visible = true; label5.visible = true; label4.visible = true; random val = new random(); int randomnumber1 = val.next(1001, 50000); ra = convert.tostring(randomnumber1); str = cs.createprivacykey(ra); label5.text = str.tostring(); }
but want key regenerate automatically after 5 minute how generate key
add timer form using designer:
- toolbox - components - timer
- drag time form
- it appear on bottom of designer
- right click on , select properties
- timer interval: number of milliseconds in 5 minutes
- enabled: true if want enabled created
- properties - events - tick: procedure called every 5 minutes.
some improvements:
- fill time interval in constructor: timespan.fromseconds(5).tomilliseconds;
- enable timer when form shown. case you're guaranteed form initialized first time timer ticks.
Comments
Post a Comment