login about faq

Hi,

I am trying to integrate Chilkat into my Android app, I tried to encrypt a file from gallery into local app folder. I checked the result is always successful, but no data is written to the encrypted file. Can you help me if I did anything wrong? I have below permission in AndroidManifest:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Below is my code:

public static CkByteData createByteData(byte[] bytes) {
    CkByteData data = new CkByteData();
    data.appendByteArray(bytes);
    return data;
}
public static CkCrypt2 createCrypt(byte[] aesKey, byte[] iv) {
    CkCrypt2 crypt = new CkCrypt2();

    boolean success = crypt.UnlockComponent("Anything for 30-day trial");
    if (success != true) {
        System.out.println(crypt.lastErrorText());
        return null;
    }

    crypt.put_CryptAlgorithm("AES");
    crypt.put_CipherMode("CTR");
    crypt.put_KeyLength(256);
    crypt.put_PaddingScheme(0);

    CkByteData keyData = createByteData(aesKey);
    crypt.put_SecretKey(keyData);

    CkByteData ivData = createByteData(iv);
    crypt.put_IV(ivData);

    return crypt;
}

public static void encrypt(File in, File out, byte[] aesKey, byte[] iv) throws IOException {
    CkCrypt2 ckCrypt2 = createCrypt(aesKey, iv);
    boolean res = ckCrypt2.CkEncryptFile(in.getAbsolutePath(), out.getAbsolutePath());
    LogHelper.log("Res " + res + ckCrypt2.lastErrorText() + " encrypted size " + out.length());
}

The log file is as below

Res trueChilkatLog:
CkEncryptFile:
DllDate: Dec  5 2014
ChilkatVersion: 9.5.0.46
UnlockPrefix: Anything for 30-day trial
Architecture: Little Endian; 32-bit
Language: Android Java
VerboseLogging: 0
inputFile: [/storage/sdcard0/DCIM/100MEDIA/IMAG0041.jpg]
outputFile: [/data/data/com.myapp.privatebox/files/xclrLjKQ0b/FILES/xclrLjKQ0b@L3N0b3JhZ2Uvc2RjYXJkMC9EQ0lNLzEwME1FRElBL0lNQUcwMDQxLmpwZw==@1413775350000@877222.jpg]
encryptionMethod: 2
inFileSize: 877222
Success.
--CkEncryptFile
--ChilkatLog
in /storage/sdcard0/DCIM/100MEDIA/IMAG0041.jpg encrypted size 0

Thank you, Thomas

asked Dec 19 '14 at 03:13

Thomas's gravatar image

Thomas
32

edited Dec 19 '14 at 03:15


Thomas,

Thanks. Turn on verbose logging by setting the CkCrypt's VerboseLogging property = true, and then post the verbose LastErrorText. Maybe we can get more information to help understand what's happening..

(I'll unsuspend your forum account. New accounts are automatically suspended because of SPAM attacks that are constant and ongoing..)

link

answered Dec 19 '14 at 08:54

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×45
×6

Asked: Dec 19 '14 at 03:13

Seen: 962 times

Last updated: Dec 19 '14 at 08:54

powered by OSQA