c# - Public Main() method is required in a public class -


i getting:

public main() method required in public class

error when running script:

using system; using system.io; using system.security.cryptography; using system.text;  public class program {  public static void main(string[] args) {      //shared 256 bit key , iv here     const string sky = "lkirwf897+22#bbtrm8814z5qq=498j5"; //32 chr shared ascii string (32 * 8 = 256 bit)     const string siv = "741952hheeyy66#cs!9hjv887mxx7@8y"; //32 chr shared ascii string (32 * 8 = 256 bit)      var stextval = "here data encrypt!!!";      var etext = encryptrj256(sky, siv, stextval);     var dtext = decryptrj256(sky, siv, etext);      console.writeline("key: " + sky);     console.writeline();     console.writeline(" iv: " + siv);     console.writeline("txt: " + stextval);     console.writeline("encrypted: " + etext);     console.writeline("decrypted: " + dtext);     console.writeline("press key exit");     console.readkey(true);   }    public static string decryptrj256(string prm_key, string prm_iv, string prm_text_to_decrypt) {      var sencryptedstring = prm_text_to_decrypt;      var myrijndael = new rijndaelmanaged() {       padding = paddingmode.zeros,       mode = ciphermode.cbc,       keysize = 256,       blocksize = 256     };      var key = encoding.ascii.getbytes(prm_key);     var iv = encoding.ascii.getbytes(prm_iv);      var decryptor = myrijndael.createdecryptor(key, iv);      var sencrypted = convert.frombase64string(sencryptedstring);      var fromencrypt = new byte[sencrypted.length];      var msdecrypt = new memorystream(sencrypted);     var csdecrypt = new cryptostream(msdecrypt, decryptor, cryptostreammode.read);      csdecrypt.read(fromencrypt, 0, fromencrypt.length);      return (encoding.ascii.getstring(fromencrypt));   }    public static string encryptrj256(string prm_key, string prm_iv, string prm_text_to_encrypt) {      var stoencrypt = prm_text_to_encrypt;      var myrijndael = new rijndaelmanaged() {       padding = paddingmode.zeros,       mode = ciphermode.cbc,       keysize = 256,       blocksize = 256     };      var key = encoding.ascii.getbytes(prm_key);     var iv = encoding.ascii.getbytes(prm_iv);      var encryptor = myrijndael.createencryptor(key, iv);      var msencrypt = new memorystream();     var csencrypt = new cryptostream(msencrypt, encryptor, cryptostreammode.write);      var toencrypt = encoding.ascii.getbytes(stoencrypt);      csencrypt.write(toencrypt, 0, toencrypt.length);     csencrypt.flushfinalblock();      var encrypted = msencrypt.toarray();      return (convert.tobase64string(encrypted));   }  } 

i not still begin able understand bug.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -