LunaticThinker.me

Thoughts on code and poetry.

Welcome to LunaticThinker.me - thoughts on code and poetry.

Atom – Changing ATOM_HOME

How many of you didn’t try to make a propert IDE from Atom by now. Let me tell you. From many many many many (I forgot how many) points of view, it’s one of the best text editors out there. And yes, with a little work, the right plugins and a lot of think through, it can be transformed into a proper IDE.

3DES Encryption With CFSCRIPT

Won’t comment much about it. We needed it, you may need it, so here it is:



    key = '62v01fVsCWHfRcW';
    text = '66866996699';
    iv = BinaryDecode("0000000000000000","hex");

    function extendKey(key, size = 24, c = "0") {
        var i = 0;
        for (i = len(key); i lt size; i = i + 1) {
            key = key & c;
        }
        return key;
    }
    
    function extendText(text, c = "0") {
        var i = 0;
        for (i = len(text) % 8; i lt 8; i = i + 1) {
            text = text & c;
        }
        return text;
    }
    
    function encrypt3desCbcCF(text, key, iv) {
        return encrypt(
            text, 
            toBase64(extendKey(key, 24, urlDecode('%00'))), 
            'DESEDE/CBC/PKCS5Padding', 
            'Base64', 
            iv
        );
    }
    
    function javaCreateObject(obj) {
        return createObject('java', obj);
    }
    
    function encrypt3desCbcJava(text, key, iv) {
        var Cipher          = javaCreateObject('javax.crypto.Cipher');
        var IvParameterSpec = javaCreateObject('javax.crypto.spec.IvParameterSpec');
        var SecretKeySpec   = javaCreateObject('javax.crypto.spec.SecretKeySpec');
    
        var jkey = SecretKeySpec.init(
            extendKey(key, 24, urlDecode('%00')).getBytes(), 
            "DESede"
        );

        var jiv = IvParameterSpec.init(iv);

        var jcipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
        jcipher.init(Cipher.ENCRYPT_MODE, jkey, jiv);
        
            
        return toBase64(jcipher.doFinal(
            text.getBytes()
        ));
    }







Check also as an example here on trycf.com