Sample Java class to decrypt AES128 encryption

I downvoted it with the comment

This is a Java question, not a Salesforce question. Stackoverflow would be a more appropriate place; also Google renders dozens of results.

But @superfell weighed in with

given that the string was encrypted by apex code, i think its reasonable to ask here.

What do other people think? I'm frankly surprised that superfell would defend the question, but I respect him a lot so I can't just dismiss his feedback.

To me, the question wasn't appropriate because:

  • it's asking for a Java code sample
  • AES is a generic standard, so the fact that this guy wants to decrypt in Java something that was encrypted in Apex make it no more Apex-related than, say, posting the same question to a Ruby discussion board because the string was encrypted in Ruby.
  • on the off chance that the OP thinks there is something specific to Apex that would make this a non-generic AES decryption question (perhaps Apex does managed IV's in an idiosyncratic way?), he/she failed to mention that.
  • even if the subject matter is relevant, the first several hits on Google for "aes decrypt java" return working code samples. I generally downvote questions that can be fully answered by the first hit of a simple Google search. (Anyone dislike that practice?)


  • Personally I'm inclined to agree with you, unless there's some reason that makes it particularly relevant to apex it should probably be on StackOverflow.
    – Matt Lacey Mod
    Oct 13, 2012 at 5:35
  • To me it seems like an integration question, are you saying that all non-native questions are out of scope?
    – superfell
    Oct 13, 2012 at 15:49
  • 1
    we're still very early on in our community building, can we not err slightly on being more inclusive to start with?
    – superfell
    Oct 13, 2012 at 15:52
  • I think that the question should stay here. On questions that are on a thin line, where they have a relation/integration to SF, I will tend to leave them here. As a new site, our aim is to attract users to our site. It's a thin line, but I tend to leave this Q here.
    – Saariko
    Oct 14, 2012 at 6:59
  • I agree. How about a question such as I have email generated from Salesforce and I need to choose a mail client that my company's employees can use to read email? Oct 14, 2012 at 12:50
  • @superfell: I'm definitely not saying non-native makes it out of scope; I think non-native that would get better answers on, say, a Java board is probably a red flag. Re: "can we not err slightly on being more inclusive to start with?" I like that sentiment, and it sounds like this one is a close call. I'll keep my hand away from the downvoting button when in doubt :)
    – jkraybill
    Oct 14, 2012 at 13:01
  • Plus a mod has deleted my original comment, so I suppose that's the equivalent of being told that I'm wrong :(
    – jkraybill
    Oct 14, 2012 at 13:06

2 Answers 2


To me it seems like an integration question, lots of people have had questions about matching encryption or hashing operations between apex and other environments. Having a question/answer show a pair of here's the apex code to encrypt it, and here's to decrypt it in java seemed to me like that would be useful for various folks building on salesforce. Yes AES is a standard but there are lots of options and things to consider like IV & Key's, string encodings etc, it doesn't seem like a slam dunk that you can find some random AES java sample and it'll be what's needed.

Yes, the person asking the question should of done more homework first, but that doesn't make the question off-topic.


I think there, are 2 issues here:

  1. Is SFSE the right place to be asking this question? There seems to be division about whether this belongs on SFSE. I'm not going to weigh in on this, It looks like a decision has been made.

  2. Is this a worthwhile question? For this I completely agree it is a bad question. It demonstrates no research or effort. No indication of what the user has tried and is failing with. For this alone I think it worth a downvote

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .