How to use the crypt.AES function in crypt

To help you get started, we’ve selected a few crypt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kinoma / kinomajs / xs6 / extensions / ssl / ssl_setup.js View on Github external
function setupSub(o, cipher)
{
	switch (cipher.cipherAlgorithm) {
	case SSL.cipherSuite.DES:
		var enc = new Crypt.DES(o.key);
		break;
	case SSL.cipherSuite.TDES:
		var enc = new Crypt.TDES(o.key);
		break;
	case SSL.cipherSuite.AES:
		var enc = new Crypt.AES(o.key);
		break;
	case SSL.cipherSuite.RC4:
		var enc = new Crypt.RC4(o.key);
		break;
	default:
		throw new Error("SSL: SetupCipher: unkown encryption algorithm");
	}
	switch (cipher.encryptionMode) {
	case SSL.cipherSuite.CBC:
	case SSL.cipherSuite.NONE:
		let h;
		switch (cipher.hashAlgorithm) {
		case SSL.cipherSuite.MD5: h = new Crypt.MD5(); break;
		case SSL.cipherSuite.SHA1: h = new Crypt.SHA1(); break;
		case SSL.cipherSuite.SHA256: h = new Crypt.SHA256(); break;
		case SSL.cipherSuite.SHA384: h = new Crypt.SHA384(); break;