例一:简单加密
- publicclassA
- {
- staticvoidmain(String[]args)throwsException
- Strings="我们abc";
- Stringkey="xyz";
- byte[]key_buf=key.getBytes("utf-8");
- //加密
- byte[]buf=s.getBytes("utf-8");
- for(inti=0;i<buf.length;i++){
- buf[i]^=key_buf[i%key_buf.length];
- }
- //解密
- 0;i<buf.length;i++){
- buf[i]^=key_buf[i%key_buf.length];
- }
- System.out.println(newString(buf,"utf-8"));
- }
例二:完整简单加密