Hallo

Pls can anyone Help me. I need this in C++ (QT5) but i can find the Answer 
in the Wiki or by Google
I*m  frustrated while i can't do this the correct way.

lg Chris



        // hashValue = "033add0a7d42df9265d52d689c8be3be";
        // symetricKey = 
"02fa45c886a79c4c06b6493031051ef8839166da576935d4cbf74b96dd8b5bea"
 
        ByteBuffer byteBufferIV = ByteBuffer.allocate(16);
        byteBufferIV.put(hashValue);
        byte[] IV = byteBufferIV.array();

        
        // bytes 0-7 are used for the counter, which is represented by
        // 8-byte
        // two-complement, Big Endian representation (equal to Java LONG), 
bytes
        // 8-15 are set to 0
        // negative values are possible (very rare)
        ByteBuffer byteBufferData = ByteBuffer.allocate(16);
        byteBufferData.putLong(longValue);
        byte[] data = byteBufferData.array();
        
        // prepare AES cipher with CTR/ICM mode, NoPadding is essential for 
the
        // decryption process. Padding could not be reconstructed due
        // to storing only 8 bytes of the cipher text (not the full 16 
bytes)
        // (or 5 bytes if the mininum length is used)
        IvParameterSpec ivSpec = new IvParameterSpec(IV);

        // TODO provider independent
        Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding", "BC");
        cipher.init(Cipher.ENCRYPT_MODE, symmetricKey, ivSpec);

        // encrypt the value with the prepared cipher
        byte[] encryptedValueComplete = cipher.doFinal(data);

        // extract bytes that will be stored in the receipt (only bytes 0-7)
        // cryptographic NOTE: this is only possible due to the use of the 
CTR
        // mode, would not work for ECB/CBC etc. modes
        byte[] encryptedValue = new byte[8]; // or 5 bytes if min.
        // length is
        // used
                
        System.arraycopy(encryptedValueComplete, 0, encryptedValue, 0, 
encryptedValue.length);

        System.out.println(encryptedValue);



-- 
-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
--- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to