qq459969411
V2EX  ›  PHP

求 DESede 的解密方法。

  •  
  •   qq459969411 · Sep 23, 2015 · 3573 views
    This topic created in 3899 days ago, the information mentioned may be changed or developed.
    这个貌似 pp 没有县城的函数,有大神有这方面的代码吗?
    1 replies    2015-09-23 09:38:43 +08:00
    jiaqidianbo
        1
    jiaqidianbo  
       Sep 23, 2015
    /**
    * 解密算法
    * 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+"------------------------");
    }
    }
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1623 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 16:29 · PVG 00:29 · LAX 09:29 · JFK 12:29
    ♥ Do have faith in what you're doing.