V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
qq459969411
V2EX  ›  PHP

求 DESede 的解密方法。

  •  
  •   qq459969411 · 2015-09-23 09:34:30 +08:00 · 2619 次点击
    这是一个创建于 3139 天前的主题,其中的信息可能已经有所发展或是发生改变。
    这个貌似 pp 没有县城的函数,有大神有这方面的代码吗?
    1 条回复    2015-09-23 09:38:43 +08:00
    jiaqidianbo
        1
    jiaqidianbo  
       2015-09-23 09:38:43 +08:00
    /**
    * 解密算法
    * cryptograph:密文
    */
    public static String decrypt(String cryptograph) throws Exception{
    /** 将文件中的私钥对象读出 */
    ObjectInputStream ois = new ObjectInputStream(new FileInputStream(PRIVATE_KEY_FILE));
    Key key = (Key) ois.readObject();
    /** 得到 Cipher 对象对已用公钥加密的数据进行 RSA 解密 */
    Cipher cipher = Cipher.getInstance(ALGORITHM);
    cipher.init(Cipher.DECRYPT_MODE, key);
    BASE64Decoder decoder = new BASE64Decoder();
    byte[] b1 = decoder.decodeBuffer(cryptograph);
    /** 执行解密操作 */
    byte[] b = cipher.doFinal(b1);
    return new String(b);
    }
    public static void main(String[] args) throws Exception {
    String source = "火车";//要加密的字符串
    System.out.println("要加密的字符串:"+source);
    String cryptograph = encrypt(source);//生成的密文
    System.out.println("生成的密文:"+cryptograph+"==================");

    String target = decrypt(cryptograph);//解密密文
    System.out.println("解密密文:"+target+"------------------------");
    }
    }
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2922 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 14:31 · PVG 22:31 · LAX 07:31 · JFK 10:31
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.