java openssl

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
public void testDESBytes3() throws Exception {
    /*
    char[] pwd = {'!', 'E', 'i', 'k', 'o', '?'};
        byte[] enc = OpenSSL.encrypt("des", pwd, "全世界无产阶级者联合起来".getBytes());
        System.out.println(Arrays.toString(enc));
        byte[] dec = OpenSSL.decrypt("des", pwd, enc);
        System.out.println(new String(dec));
 
 
     */
    BufferedInputStream in = new BufferedInputStream(new FileInputStream("c:/des-cfb8.raw"));
    ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
    byte[] temp = new byte[1024];
    int size = 0;
    while ((size = in.read(temp)) != -1) {
        out.write(temp, 0, size);
    }
    in.close();
 
    byte[] content = out.toByteArray();
 
    char[] pwd = "changeit".toCharArray();
    System.out.println("Readed bytes count:" + content.length);
   // byte[] encrypted = Util.streamToBytes(in);
    //String cipher = "fileName.substring(0, x)";
    String cipher ="des-cfb8";
    byte[] result = OpenSSL.decrypt(cipher, pwd, content);
    String s = new String(result, "ISO-8859-1");
    System.out.println(s);
    System.out.println("hello,world");
    }

  

posted on   lydstory  阅读(349)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2019-11-23 unix域套接字
2019-11-23 Java 出现cannot be resolved to a type
2019-11-23 jni接口
2019-11-23 c语言线程池
2019-11-23 通过ffi在nodejs中调用动态链接库(.so文件)
2019-11-23 db2 mysql oracle 邮件 tomcat ssh telnet ftp samba 账号密码
2019-11-23 springboot与spring framework之间的关系

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示