久久久久久久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)
主站蜘蛛池模板: 国产成人影院 | 国产欧美精品一区二区 | 91精品国产综合久久精品图片 | 中文字幕视频在线看 | 成人国产精品久久久 | 99久久免费精品国产男女高不卡 | 日韩福利在线观看 | 久久久青草婷婷精品综合日韩 | www亚洲成人| www.色综合 | 福利视频一区二区 | 国内精品视频一区二区三区 | 视频1区| 日韩欧美国产一区二区三区 | 国产一级片在线观看视频 | 黑人性hd | 九九av| www.四虎.com| 黑人巨大精品欧美黑白配亚洲 | 91一区二区 | 国产成人艳妇aa视频在线 | 亚洲一区二区三区福利 | 中文av电影 | 色视频在线免费观看 | 一区二区三区精品在线 | 国产农村一级国产农村 | 亚洲三区在线播放 | 二区视频 | 精品久久久久久亚洲综合网站 | 亚洲www| 超碰人人人 | 日本不卡一区 | 中文字幕日韩一区 | 91在线视频精品 | 久色网| 亚洲精品在线免费 | 中文字幕第九页 | 九九在线视频 | 日本高清视频网站 | 日韩在线免费视频 | 国产成人一区二区三区电影 |