四叶草网络安全学院第一届ctf比赛题目WP
大家好关于这次比赛密码学和部分移动安全如下
没错在这里我们来解题吧(不要吐槽我,嘴下饶人)
1
某加密算法实现如下
import java.nio.charset.Charset;
public class DeEnCode {private static final String key0 = "2021.2.26";private static final Charset charset = Charset.forName("UTF-8");private static byte[] keyBytes = key0.getBytes(charset);public static String encode(String enc){byte[] b = enc.getBytes(charset);for(int i=0,size=b.length;i<size;i++){for(byte keyBytes0:keyBytes){b[i] = (byte) (b[i]^keyBytes0);}}return new String(b);}
加密flag后为:Q[VPLDRTwQBF^YJ
写出解密算法求出flag
解:
mport java.nio.charset.Charset;
public class DeEnCode {private static final String key0 = "2021.2.26";private static final Charset charset = Charset.forName("UTF-8");private static byte[] keyBytes = key0.getBytes(charset);public static String decode(String dec){byte[] e = dec.getBytes(charset);byte[] dee = e;for(int i=0,size=e.length;i<size;i++){for(byte keyBytes0:keyBytes){e[i] = (byte) (dee[i]^keyBytes0);}}return new String(e);}public static void main(String[] args) {String dec = decode("Q[VPLDRTwQBF^YJ")
;
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!