我試圖加密使用TripleDESEncryption一個字符串,跟着這個例子中,我發現在互聯網上(鏈接:http://www.blackberry.com/developers/docs/3.6api/net/rim/device/api/crypto/doc-files/CryptoTest.html#sampleMD5Digest):黑莓TripleDESEncryption輸出轉換成字符串
// sampleTripleDESEncryption
private static int sampleTripleDESEncryption(byte[] secretKey, byte[] plainText, byte[] cipherText) throws CryptoTokenException, CryptoUnsupportedOperationException
{
// Create a new Triple-DES key based on the 24 bytes in the secretKey array
TripleDESKey key = new TripleDESKey(secretKey);
// Create a new instance of the Triple-DES encryptor engine, passing in the newly
// created key
TripleDESEncryptorEngine engine = new TripleDESEncryptorEngine(key);
// Encrypt one block (8 bytes) of plainText into cipherText
engine.encrypt(plainText, 0, cipherText, 0);
// Return the block size of the engine
return engine.getBlockLength();
}
不過,我想加密的數據轉換字符串。我不確定cipherText變量是否是要轉換的變量。任何幫助?我將如何轉換它?
這是正確的。 Chiper文本現在保留加密數據 –
你是什麼意思這是正確的?該方法返回一個int。我想將加密的數據轉換爲可讀的形式。你知道如何轉換它嗎? –