久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

解密(使用 PHP)Java 加密(PBEWithMD5AndDES)

Decrypt ( with PHP ) a Java encryption ( PBEWithMD5AndDES )(解密(使用 PHP)Java 加密(PBEWithMD5AndDES))
本文介紹了解密(使用 PHP)Java 加密(PBEWithMD5AndDES)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

有人讓我用 PHP 解密一個用以下 Java 類加密的字符串.

Someone asked me to decrypt with PHP a string encrypted with the following Java Class.

public class CryptoLibrary {

private Cipher encryptCipher;
private sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder();

public CryptoLibrary() throws SecurityException{

    java.security.Security.addProvider(new com.sun.crypto.provider.SunJCE());

    char[] pass = "NNSHHETJKKSNKH".toCharArray();
    byte[] salt = {
    (byte) 0xa3, (byte) 0x21, (byte) 0x24, (byte) 0x2c,
    (byte) 0xf2, (byte) 0xd2, (byte) 0x3e, (byte) 0x19 };

    init(pass, salt, iterations);

}

public void init(char[] pass, byte[] salt, int iterations)throws SecurityException{

        PBEParameterSpec ps = new javax.crypto.spec.PBEParameterSpec(salt, 20);
        SecretKeyFactory kf = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
        SecretKey k = kf.generateSecret(new javax.crypto.spec.PBEKeySpec(pass));

        encryptCipher = Cipher.getInstance("PBEWithMD5AndDES/CBC/PKCS5Padding");
        encryptCipher.init(Cipher.ENCRYPT_MODE, k, ps);
    }
}

public synchronized String encrypt(String str)  throws SecurityException{
    if(str!=null){
        byte[] utf8 = str.getBytes("UTF8");
        byte[] enc = encryptCipher.doFinal(utf8);
        return encoder.encode(enc);
    }
    else {
        return null;
    }
}
}

我不懂任何 Java,所以我需要一些幫助來理解這種加密.

I don't know any Java so I need some help to understand this encryption.

1) 這條線是什么意思?PBEParameterSpec ps = new javax.crypto.spec.PBEParameterSpec(salt,20);

1) what is the meaning of this line? PBEParameterSpec ps = new javax.crypto.spec.PBEParameterSpec(salt,20);

2) 我應該為第一個參數使用什么值string mcrypt_encrypt(string $cipher, string $key, string $data, string $mode [, string $iv])

2) what value should I use for the first parameter of string mcrypt_encrypt ( string $cipher , string $key , string $data , string $mode [, string $iv ] )

3) 我什么時候應該在我的 php 腳本中使用 MD5?

3) When should I use MD5 in my php script?

推薦答案

1) 創建基于密碼的加密的參數,包含在哈希計算中的鹽,以及哈希方法執行的迭代次數(在它自己的輸出上).它用于擊敗彩虹表攻擊,基本上攻擊者必須經過相同次數的迭代來檢查密碼是否正確,并且他不能使用預先計算的表,因為每個密碼的鹽都會不同(所以你看不到如果某人與另一個用戶的密碼相同).

1) It creates the parameters for Password Based Encryption, the salt, which is included in the hash calculations, and the number of iterations that the hash method is executed (on it's own output). It is used to defeat rainbow table attacks, basically an attacker has to go through the same number of iterations to check if the password is correct, and he cannot use a precalculated table because the salt will be different for each password (so you cannot see if somebody has the same password as another user).

2) MCRYPT_DES,你需要 MCRYPT_MODE_CBC 作為模式,當然還有 PKCS#5 填充.

2) MCRYPT_DES, and you will need MCRYPT_MODE_CBC for the mode, and PKCS#5 padding of course.

3) 僅當您絕對確定其弱點未暴露或絕對需要兼容性時.幸運的是,它對于密鑰派生功能相對安全.下載 PHP 的 pbkdf1 方法并將其放入其中 - 如果尚未包含.

3) Only when you are absolutely sure that its weaknesses are not exposed or when absolutely required for compatibility. Fortunately, it is relatively secure for key derivation functions. Download a pbkdf1 method for PHP and put it in there - if not already included.

這篇關于解密(使用 PHP)Java 加密(PBEWithMD5AndDES)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Java Remove Duplicates from an Array?(Java從數組中刪除重復項?)
How to fix Invocation failed Unexpected Response from Server: Unauthorized in Android studio(如何修復調用失敗來自服務器的意外響應:在 Android 工作室中未經授權)
AES encryption, got extra trash characters in decrypted file(AES 加密,解密文件中有多余的垃圾字符)
AES Error: Given final block not properly padded(AES 錯誤:給定的最終塊未正確填充)
Detecting incorrect key using AES/GCM in JAVA(在 JAVA 中使用 AES/GCM 檢測不正確的密鑰)
AES-256-CBC in Java(Java 中的 AES-256-CBC)
主站蜘蛛池模板: 日韩在线观看中文字幕 | 一区二区电影网 | 激情福利视频 | 成人亚洲片| 黑人巨大精品欧美黑白配亚洲 | 亚洲免费精品一区 | 成人在线一区二区三区 | 亚洲最大看片网站 | 国产精品电影在线观看 | 亚洲啊v在线 | 久久精品国产亚洲 | 羞羞网站免费观看 | 欧美高清视频一区 | 亚洲国产成人av好男人在线观看 | 中文字幕综合在线 | 精品久久久久久久久久久久久久 | 久久久久国产精品午夜一区 | 91成人午夜性a一级毛片 | 羞羞午夜 | 一区二区三区电影在线观看 | 人人玩人人添人人澡欧美 | 亚洲精品电影网在线观看 | 欧美一级片黄色 | 欧美日韩在线高清 | 国产精品久久av | 日本韩国欧美在线观看 | 日韩精品影院 | 精品国模一区二区三区欧美 | 免费看片国产 | 韩日三级| 国产高清在线观看 | 久久天堂 | 成人精品一区二区三区 | 国产在线二区 | 一区二区在线看 | 久久免费视频观看 | 欧美精品一区二区三区在线播放 | 日韩精品在线观看一区二区 | 欧美成人一区二免费视频软件 | 91精品国产91久久久久久最新 | 成人一区二区三区 |