forms - C# RNGCryptoservice disposing in separate class -


here code http://pastebin.com/zsh938bg

i using rngcryptoserviceprovider secure random byte block (not implemented fully)

on line 160, making new rngcryptoserviceprovider(), in subclass encryption. how can dispose() when program exits? (its form)

i don't want public method in encryption class because getting list every function in there used in listbox via reflection.(line 27 , 95)

btw stack overflow says oh should document question , provide links sources, , when try to, oh yeah, need 10 rep more 2 links ftw. sorry had cut out few links.

also didn't ask on security.stackexchange.com because can't understand of them saying. i'm not advanced yet.

you should use dispose pattern: implement idisposable yourself, call on closing event.

class encryption : idisposable { [....]     public void dispose()     {         dispose(true);         gc.suppressfinalize(this);     }     protected virtual void dispose(bool disposing){         if (disposing)         {             if(provider != null) provider.dispose();         }     } } 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -