반응형

AES256를 이용한 암호화 복호화를 만들어보았습니다.

//암호화
        AESencryption(value){
            //let secretKey = '%^qwe&*()123rty45!@#$67io890up!Q';
            //let secretKey = '%^qwe&*()123rty45!@#!Q';

            let secretKey = process.env.VUE_APP_AES_KEY;
            console.log('secretKey : ',secretKey);

            const cipher = CryptoJS.AES.encrypt(value, CryptoJS.enc.Utf8.parse(secretKey), {
                iv: CryptoJS.enc.Utf8.parse(""),
                padding: CryptoJS.pad.Pkcs7,
                mode: CryptoJS.mode.CBC
            });
            return cipher.toString();
        },
        //복호화
        ASEdecryption(value){
            let secretKey = process.env.VUE_AES256_KEY;

            const cipher = CryptoJS.AES.decrypt(value, CryptoJS.enc.Utf8.parse(secretKey), {
                iv: CryptoJS.enc.Utf8.parse(""),
                padding: CryptoJS.pad.Pkcs7,
                mode: CryptoJS.mode.CBC
            });
            return cipher.toString(CryptoJS.enc.Utf8);
        },

+ Recent posts