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 7643461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:27:17+00:00 2026-05-31T09:27:17+00:00

I´m using this code to Encrypt and Decrypt in Java and Android some Strings

  • 0

I´m using this code to Encrypt and Decrypt in Java and Android some Strings and in each system I get a different value.

The code I’m using comes from http://www.androidsnippets.com/encryptdecrypt-strings (I won’t paste it beacuse it’s quite big).

For example in Android for encrypting “aa” I get this:
1C6BD31C57F42ACFD0EDD2DD5B7A92CA

and exactly the same String with the same key as seed in Java I get:
61FAD1203B7AC92AD9345771AA273DA5

Any idea?

Thanks in advance!

  • 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-31T09:27:19+00:00Added an answer on May 31, 2026 at 9:27 am

    This is just my guess, but I think the reason is your key derivation. I’m not really a Java developer though, so I might not be understanding the code correctly.

    This code always calls getRawKey() when you encrypt and decrypt. getRawKey() looks like it takes something they call a seed, or your shared secret, and uses it to compute a new random key to do the actual encryption/decryption.

    SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
        sr.setSeed(seed);
        kgen.init(128, sr); // 192 and 256 bits may not be available
        SecretKey skey = kgen.generateKey();
    

    According to Java docs found here, setSeed() “Reseeds this random object. The given seed supplements, rather than replaces, the existing seed.”

    My guess is that the initial state of the RNG is different on each system/platform, and thus it’s giving you different results. You should fix the key derivation to something more standard and consistent, or use an already established crypto system, like PGP in the Bouncy Castle libraries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this code snippet to encrypt/decrypt data in my app's database: http://www.androidsnippets.com/encryptdecrypt-strings It
I'm trying to encrypt and decrypt files with C++, using this code: #include <iostream>
I am using the code found at http://pastie.org/966473 to encrypt/decrypt strings using AES in
While using this code, i can't get any results... Ext.define('Teste.view.Main', { extend: 'Ext.Container', initialize:
After using this code to get my link to show me 3 database entrys
I'm using Bouncy Castle to encrypt strings to send them to my java web
I have a CryptoAPI code to encrypt\ decrypt given data using AES-128 and a
Using this code to zip a folder and it works perfect on small files
Using this code var html='<div class=somediv></div>'; var target=document.getElementById('contentArea'); target.appendChild(html); I'm getting Uncaught Error: NOT_FOUND_ERR:
Using This code: I am tring to fill the page with the data and

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.