All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.anysoft.util.code.coder.Hex Maven / Gradle / Ivy

There is a newer version: 1.6.17
Show newest version
package com.anysoft.util.code.coder;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.anysoft.util.KeyGen;
import com.anysoft.util.code.Coder;
import com.anysoft.util.code.util.ByteUtil;

/**
 * Hex转换
 * @author yyduan
 * @version 1.6.12.7 [20181108 duanyy] 
* - 改造coder框架
*/ public class Hex implements Coder { protected static final Logger LOG = LoggerFactory.getLogger(Hex.class); public String getAlgorithm() { return "Hex"; } @Override public String createKey(){ return KeyGen.getKey(8); } @Override public String createKey(String init){ return init; } @Override public String encode(String data,String key) { return encode(data,key,true,true); } @Override public String encode(String data, String key, boolean hex, boolean urlSafe) { return ByteUtil.byte2string(data.getBytes(), true, true); } @Override public String decode(String data,String key) { return decode(data,key,true,true); } @Override public String decode(String data, String key, boolean hex, boolean urlSafe) { return new String(ByteUtil.string2byte(data, true, false)); } @Override public String createKey(String init, boolean hex, boolean urlSafe) { return init; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy