package org.squirrelframework.cloud.resource.codec;

import org.apache.commons.codec.binary.Base64;

import javax.crypto.Cipher;
import java.security.Key;

/**
 * Created by kailianghe on 15/12/21.
 */
public class CipherDecoder implements Decoder {
    private final Key key;

    public CipherDecoder(Key key) {
        this.key = key;
    }

    @Override
    public String decode(String value) throws Exception {
        Cipher cipher = Cipher.getInstance(this.key.getAlgorithm());
        cipher.init(Cipher.DECRYPT_MODE, this.key);
        return new String(cipher.doFinal(Base64.decodeBase64(value.getBytes())));
    }
}

@@ -92,16 +92,76 @@
 .Base64;
+%0Aimport org.squirrelframework.cloud.utils.CloudConfigCommon;
 %0A%0Aimport
@@ -610,19 +610,40 @@
 urn 
-new 
+CloudConfigCommon.bytes2
 String(
+ 
 ciph
@@ -691,16 +691,17 @@
 ytes()))
+ 
 );%0A    %7D

update code