1

我正在尝试使用 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 变量是否是要转换的变量。有什么帮助吗?我将如何转换它?

4

1 回答 1

2

你只是不希望结果会通过参数返回。

所以首先在chiperText. 调用该方法,您将得到chiperText具有返回长度(返回值)的缓冲区。

于 2012-08-31T09:41:04.117 回答