本文整理汇总了Java中com.litesuits.common.data.cipher.Cipher类的典型用法代码示例。如果您正苦于以下问题:Java Cipher类的具体用法?Java Cipher怎么用?Java Cipher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Cipher类属于com.litesuits.common.data.cipher包,在下文中一共展示了Cipher类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import com.litesuits.common.data.cipher.Cipher; //导入依赖的package包/类
public Object get(String key, Cipher cipher) {
try {
String hex = get(key, (String) null);
if (hex == null) return null;
byte[] bytes = HexUtil.decodeHex(hex.toCharArray());
if (cipher != null) bytes = cipher.decrypt(bytes);
Object obj = ByteUtil.byteToObject(bytes);
Log.i(TAG, key + " get: " + obj);
return obj;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例2: put
import com.litesuits.common.data.cipher.Cipher; //导入依赖的package包/类
public void put(String key, Object ser, Cipher cipher) {
try {
Log.i(TAG, key + " put: " + ser);
if (ser == null) {
sp.edit().remove(key).commit();
} else {
byte[] bytes = ByteUtil.objectToByte(ser);
if (cipher != null) bytes = cipher.encrypt(bytes);
put(key, HexUtil.encodeHexStr(bytes));
}
} catch (Exception e) {
e.printStackTrace();
}
}