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();
} 

ただし、暗号化されたデータを文字列に変換したいと思います。暗号文変数が変換される変数であるかどうかはわかりません。何か助けはありますか?どのように変換しますか?

4

1 に答える 1

2

結果がパラメーターを介して返されるとは思わないだけです。

そのため、まず に十分なバッファを割り当てchiperTextます。メソッドを呼び出すと、返されchiperTextた長さ (戻り値) を持つバッファーが返されます。

于 2012-08-31T09:41:04.117 に答える