我明白了...... :)
In Python
from Crypto.Cipher import DES
from datetime import datetime, timedelta
import sys
import re
import base64
#used for decryting the cipher text
def parseToken(str):
cipher = DES.new('oldhouse',DES.MODE_CFB, 'houseold')
resolved=cipher.decrypt(base64.b64decode(str))
return resolved
在java中
protected String encrypt(String token) throws Exception {
// Instantiate the cipher
final SecretKeySpec key = new SecretKeySpec("oldhouse".getBytes("ISO-8859-1"), "DES");
AlgorithmParameterSpec paramSpec = new IvParameterSpec("houseold".getBytes());
//function used to encrypt
protected String encrypt(String token) throws Exception {
// Instantiate the cipher
final SecretKeySpec key = new SecretKeySpec("oldhouse".getBytes("ISO-8859-1"), "DES");
AlgorithmParameterSpec paramSpec = new IvParameterSpec("houseold".getBytes());
Cipher cipher = Cipher.getInstance("DES/CFB8/NoPadding");
cipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
byte[] binaryData = cipher.doFinal(token.getBytes("ISO-8859-1"));
return new String(org.apache.commons.codec.binary.Base64.encodeBase64(binaryData), "ISO-8859-1");
}
试试这个你会得到.....
答案 0 :(得分:1)
是否可以不提供加密密钥,我们可以获得实际数据?
我怀疑如果可以,那就会破坏加密的目的。以不同的方式。如果您能找到一种方法,那么您已经确定加密算法很容易破解,因此无用。