Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6907411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:25:52+00:00 2026-05-27T08:25:52+00:00

How can I do AES 256 encryption in Blackberry… I am using for encryption

  • 0

How can I do AES 256 encryption in Blackberry…

I am using for encryption : but not get data AES256 standard :

 private static byte[] encrypt( byte[] keyData, byte[] data ) throws CryptoException, IOException
    {
        // Create the AES key to use for encrypting the data.
        // This will create an AES key using as much of the keyData
        // as possible.
        AESKey key = new AESKey( keyData );

        // Now, we want to encrypt the data.
        // First, create the encryptor engine that we use for the actual
        // encrypting of the data.
        AESEncryptorEngine engine = new AESEncryptorEngine( key );

        // Since we cannot guarantee that the data will be of an equal block
        // length we want to use a padding engine (PKCS5 in this case).
        PKCS5FormatterEngine fengine = new PKCS5FormatterEngine( engine );

        // Create a BlockEncryptor to hide the engine details away.
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        BlockEncryptor encryptor = new BlockEncryptor( fengine, output );

        // Now, all we need to do is write our data to the output stream.
        // But before doing so, let's calculate a hash on the data as well.
        // A digest provides a one way hash function to map a large amount
        // of data to a unique 20 byte value (in the case of SHA1).
        SHA1Digest digest = new SHA1Digest();
        digest.update( data );
        byte[] hash = digest.getDigest();

        // Now, write out all of the data and the hash to ensure that the
        // data was not modified in transit.
        encryptor.write( data );
        encryptor.write( hash );
        encryptor.close();
        output.close();

        // Now, the encrypted data is sitting in the ByteArrayOutputStream.
        // We simply want to retrieve it.
        return output.toByteArray();
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:25:53+00:00Added an answer on May 27, 2026 at 8:25 am

    This gave me “wQVge+rn7HGVs17a82GKTw==”. Enjoy:

    private static byte[] encrypt(byte[] keyData, byte[] data)
            throws CryptoException, IOException {
        // Create the AES key to use for encrypting the data.
        // This will create an AES key using as much of the keyData
        // as possible.
        AESKey key = new AESKey(keyData);
    
        // Now, we want to encrypt the data.
        // First, create the encryptor engine that we use for the actual
        // encrypting of the data.
        AESEncryptorEngine engine = new AESEncryptorEngine(key);
    
        // Since we cannot guarantee that the data will be of an equal block
        // length we want to use a padding engine (PKCS5 in this case).
        PKCS5FormatterEngine fengine = new PKCS5FormatterEngine(engine);
    
        // Create a BlockEncryptor to hide the engine details away.
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        BlockEncryptor encryptor = new BlockEncryptor(fengine, output);
    
        encryptor.write(data);
        encryptor.close();
        output.close();
    
        // Now, the encrypted data is sitting in the ByteArrayOutputStream.
        // We simply want to retrieve it.
        return output.toByteArray();
    }
    
    .... somewhere else
    
    byte[] keyData = "@mbe0RcM$@mbe0RcM$@mbe0RcM$@mbe0".getBytes(); 
    byte[] data = "S2526".getBytes();
    byte[] encryptedInAES;
    try {
        encryptedInAES = encrypt(keyData, data);
    } catch (Exception e) {
        Dialog.alert("Failed to AES: " + e);
        return;
    }
    
    byte[] encodedInBase64 = null;
    try {
        encodedInBase64 = Base64OutputStream.encode(
            encryptedInAES, 0, encryptedInAES.length, false, false
        );
    } catch (IOException e) {
        Dialog.alert("Failed to Base64: " + e);
        return;
    }
    
    try {
        String encodedStr = new String(encodedInBase64, "UTF-8");
        Dialog.alert("Result: " + encodedStr);
    } catch (UnsupportedEncodingException ignored) {}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We know we can encrypt a file with openssl using this command: openssl aes-256-cbc
I need to implement 256 bit AES encryption, but all the examples I have
We are adding AES 256 bit encryption to our server and client applications for
I need to create an application that decrypts data that is encrypted using AES
KeyGenerator kgen = KeyGenerator.getInstance(AES); kgen.init(128); // 192 and 256 bits may not be available
I've been trying to get AES encryption and decryption working for some time in
I'm implementing encryption / decryption using Java Cipher and AES. Everything is working well
My software is using AES Rijndael. I am using a SHA-256 hash to generate
I have this code for AES encryption, can some one verify that this code
Can I get a 'when to use' for these and others? <% %> <%#

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.