© 2005 Goetz Heller
Table of Contents Description Source Code Subclass Template Copyright Note backThese examples demonstrate instantiation of valid and invalid hash algorithm classes.
var hashAlgorithm = core.getClassByID('system.security.encryption.hash.hashAlgorithm'); // ========================================================================================= // try to instantiate hashAlgorithm // ========================================================================================= document.write('<' + 'h4>hashAlgorithm - Instantiation<' + '/h4>'); try { core.createInstance('system.security.encryption.hash.hashAlgorithm'); document.write('hashAlgorithm successfully instantiated'); } catch (e) { document.write(e.message); } // ========================================================================================= // try to instantiate MD4 // ========================================================================================= document.write('\n<' + 'h4>MD4 - Instantiation<' + '/h4>'); try { var alg = 'MD4'; var inst = system.security.encryption.hash.hashAlgorithm.create(alg); document.write('algorithm ' + inst + ' successfully instantiated'); } catch (e) { document.write(e.message); } // ========================================================================================= // try to instantiate MD5 // ========================================================================================= document.write('\n<' + 'h4>MD5 - Instantiation<' + '/h4>'); try { var alg = 'MD5'; var inst = system.security.encryption.hash.hashAlgorithm.create(alg); document.write('algorithm ' + inst + ' successfully instantiated'); } catch (e) { document.write(e.message); } // ========================================================================================= // try to instantiate base64 // ========================================================================================= document.write('\n<' + 'h4>base64 - Instantiation<' + '/h4>'); try { var alg = 'system.utility.base64'; var inst = system.security.encryption.hash.hashAlgorithm.create(alg); document.write('algorithm ' + inst + ' successfully instantiated'); } catch (e) { document.write(e.message); } // ========================================================================================= // try to instantiate MDD4 // ========================================================================================= document.write('\n<' + 'h4>MDD4 - Instantiation<' + '/h4>'); try { var alg = 'MDD4'; var inst = system.security.encryption.hash.hashAlgorithm.create(alg); document.write('algorithm ' + inst + ' successfully instantiated'); } catch (e) { document.write(e.message); }