我正在尝试使用 TripleDESEncryption 加密字符串并遵循我在互联网上找到的这个示例(链接: http: //www.blackberry.com/developers/docs/3.6api/net/rim/device/api/crypto/doc -files/CryptoTest.html#sampleMD5Digest):
// 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 变量是否是要转换的变量。有什么帮助吗?我将如何转换它?