Base64编码+两串异或操作
来源:互联网 发布:leslie矩阵预测人口 编辑:程序博客网 时间:2024/06/06 09:12
使用到jar包:commons-codec.jar
/** * base64编码 * * @param s * @param key * @return */public static String encode(String s, String key) {return base64Encode(xorWithKey(s.getBytes(), key.getBytes()));}/** * base64解码 * * @param s * @param key * @return */public static String decode(String s, String key) {return new String(xorWithKey(base64Decode(s), key.getBytes()));}private static byte[] base64Decode(String s) {return Base64.decodeBase64(s);}private static String base64Encode(byte[] bytes) {byte[] encodeBase64 = Base64.encodeBase64(bytes);return new String(encodeBase64);}/** * 两个字符串异或 * * @param a * @param key * @return */public static byte[] xorWithKey(byte[] a, byte[] key) {byte[] out = new byte[a.length];for (int i = 0; i < a.length; i++) {out[i] = (byte) (a[i] ^ key[i % key.length]);}return out;}
参考:http://www.bluefaq.com/java/79964
0 0
- Base64编码+两串异或操作
- java Base64 编码操作
- base64操作图片——编码解码
- Base64编码
- Base64编码
- base64编码
- BASE64编码
- Base64编码
- BASE64编码
- base64 编码
- Base64编码
- Base64编码
- Base64编码
- base64编码
- BASE64编码
- base64编码
- BASE64编码
- base64编码
- Eclipse debug的按钮不见了
- @Resource注解
- LVS-DR简单模型实现负载均衡
- CocoaPods
- java读取txt文件
- Base64编码+两串异或操作
- 建筑建模学习笔记2——3DMax房屋框架建模
- 使用未公开关键字在 C# 中导入外部 printf 等参数数量可变函数 [2] C# 实现
- Hash表的简单应用
- Matlab工具箱导入
- 压缩-解压
- 最小哈希和局部性哈希理论
- QT显示图片
- SDWebImage