How to know whether data is being AES crypted or not?

Hi Forum,
I used AES crypting with an initial vector and a SecretKey.
The problem is , for backward compatibility I need to check if the data had been crypted or not?
if not crypted I need to show them in plain readable format instead of decrypting them.
below is my Encryption/Decryption class
public class AesEncryption
    private  final String CRYPTO_ALGO_= "AES";
    Cipher aesCipher_;
// Create an 16-byte initialization vector
    private final byte[] initialVector_ = new byte[]{
                                                    (byte)0x8E, 0x12, 0x39, (byte)0x9C,
                                                          0x07, 0x72, 0x6F, 0x5A,
                                                    (byte)0x8E, 0x12, 0x39,(byte)0x9C,
                                                          0x07, 0x72, 0x6F, 0x5A
    private final SecretKey key_ = new SecretKeySpec(initialVector_, CRYPTO_ALGO_);
    public AesEncryption()
         *  Create a Cipher by specifying the following parameters
         *     Algorithm name - here it is AES
        try
             aesCipher_ = Cipher.getInstance(CRYPTO_ALGO_);
        catch (NoSuchAlgorithmException e)
            e.printStackTrace();
        catch (NoSuchPaddingException e)
            e.printStackTrace();
    public  String encryptPassword(String password)
        String strEncryptedText ="";
        try{
         *  Initialize the Cipher for Encryption with secret key
        aesCipher_.init(Cipher.ENCRYPT_MODE,key_);
         *   Encrypt the password
        byte[] byteDataToEncrypt = password.getBytes();
        byte[] byteCipherText = aesCipher_.doFinal(byteDataToEncrypt);
               strEncryptedText = new BASE64Encoder().encode(byteCipherText);
        catch (InvalidKeyException e)
             e.printStackTrace();
        catch (BadPaddingException e)
             e.printStackTrace();
        catch (IllegalBlockSizeException e)
             e.printStackTrace();
        return strEncryptedText;
    public String decryptPassword(String encryptedPassword)
        String strDecryptedText = "";
        try
             * Decrypt the Data
            byte[] byteCipherText = new BASE64Decoder().decodeBuffer(encryptedPassword.trim());
            aesCipher_.init(Cipher.DECRYPT_MODE,key_,aesCipher_.getParameters());
            byte[] byteDecryptedText = aesCipher_.doFinal(byteCipherText);
            strDecryptedText = new String(byteDecryptedText);
        catch (InvalidKeyException invalidKey)
             invalidKey.printStackTrace();
        catch (BadPaddingException badPadding)
             badPadding.printStackTrace();
        catch (IllegalBlockSizeException illegalBlockSize)
             illegalBlockSize.printStackTrace();
        catch (InvalidAlgorithmParameterException invalidParam)
             invalidParam.printStackTrace();
        catch (IOException e)
            e.printStackTrace();
        return strDecryptedText;
} I just want to have a method like boolean isAESEncrypted(String data){ ????  } in my class.
Could anybody give a helping hand for the same?
Many thanks in advance
Edited by: jagabandhu on Sep 16, 2010 10:54 AM

jagabandhu wrote:
I do have a choice to store the encrypted data only in 'varchar' format so I have to encrypt and store the password without changing the column data type in the database!
Again many thanks for 'Notes:' these are definitely helpful.
sabre150 wrote:
If you have a choice, then you should add a digest of the cleartext to the ciphertext. ...I fear if I use any MessageDigest , my password will be byte[] instead present String format.Not relevant since you Base64 encode the ciphertext you can also Base64 encode the digest!
for e.g.
[http://gmailassistant.sourceforge.net/src/org/freeshell/zs/common/Encryptor.java.html]
Could you please further guide me if I am in the right track?I thought I had guided you! I have pointed out what I see as the flaws in your code and I think you should use the more normal approach of just using a randomly seeded Message Digest.
>
FYI : I do not need a serious encryption format as per the present requirement. :)That is not serious encryption since it has at least 3 major security flaws.
>
Edited by: jagabandhu on Sep 16, 2010 1:17 PM

Similar Messages

  • How to know whether balance carry forward has happened or not

    How to know , whether balance carry forward has happened or not for a perticular GL account or for the company code as a whole?

    If the account is a balance sheet account, you can merely look at the beginning balance for the same balance sheet account for the beginning of the next fiscal year FS10N. The beginning balance will equal the previous year's ending balance. Since this does not happen automatically, you will know that carry forward has not been done if a balance sheet account has no beginning balance in the following fiscal year.
    If you are talking about For P&L GL accounts, you can check the acvitity in the retained earnings accounts to make sure that they have been updated for the P&L activity. You can identify the retained earnings account by looking at the master data for the account in the section "P&L statmt acct type" and pulling up the menu to see the actual retained earnings account number.
    You can perform carry foward (GVTR) as many times as you want but normally once it has been ran, any postings to a  previous fiscal year are automatically carried forward to the current year after that initial run.

  • How to know whether my system is J2EE compliant or not?

    How to know whether my system is J2EE compliant or not?
    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    C:\Documents and Settings\Administrator>java -version
    java version "1.6.0_16"
    Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
    Java HotSpot(TM) Client VM (build 14.2-b01, mixed mode, sharing)Is my box J2EE compliant?

    Trust me - I've been developing on an XP box for years and Java 1.6 for a good amount of time. This has been using Tomcat, JBoss, and Glassfish (and I try hard to forget about Oracle OC4J). These are application servers that implement part (Tomcat) or all (the rest) of the J2EE specification.
    Having said that, you'll want at least 2GB of RAM and a hundred or so megabytes of disk space. Less RAM will work but slowly. A reasonable processor (I'd say at least 1.5GHz or above) will speed development.

  • How to know whether a country is in Europe or not?

    I want to know <b>whether a country is in EUROPE or not?</b> Pls help me in this regard.

    Hi,
    If you want to check you can just go to the website
    http://europa.eu/abc/european_countries/index_en.htm
    and check .
    Close the thread if it solves your purpose.
    Award Points if it helps.
    -Gaurang

  • How to know  Whether Partition is done for Cube or not

    Hi All,
    I need information regarding Partition of a cube.
    a)How do i know the Partition is done or not for Cube
    b)On what basis we should make parttion of Cube.
    Thanks and Regards,
    C.V.

    There are several threads on partitioning, so it would be a good start for this question (as with any question) to search the BI forums on "Partitioning" and review thsoe first.
    Some basic considerations on partitioning -
    - Your DB must support Range partitioning to permit partitioning your InfoCube. The option will be greyed out if it is not available.
    - InfoCube must be empty to be partitioned.
    - InfoCube can only be partitioned on 0FISCPER or 0CALMONTH.  You can define it so that you have a partition for each month/fiscper, or so that each partition will hold a few or several months of data.
    - Generally, you would not partition small cubes.
    - Thru BW 3.5 Aggregates automatically get partitioned the sme way the InfoCube is partitioned as long as the partitioning characteristic is in the aggregate.  In 2004s, I believe you have options as to whether an aggregate gets partitioned or not.
    - Partitioning may be done for query performance reasons and data administration.  If the queries on the InfoCube regularly run with restrictions/filters on the partitioning characteristic (FISCPER or CALMONTH), the database will "prune" any partitions that do not contain the FISCPER/CALMONTH value(s), so that it does not need to consider them , e.g. most of your users only run a sales query for the current and previous month, but your cube contains 3 years of data.  By partitioning on CALMONTH (we'll assume 1 partition / month), the database will exclude all but the two partitions from consideration.  This could help query performance a lot. or maybe only a little, depending on a variety of other factors.
    Again - it is important that the queries restrict onthe partitioning characteristic to be of any value on query performance.  So don't partition on FISCPER if all the queries use CALMONTH for restrictions.
    The data adminsitration reason you might partition is to improve selective deletion or archiving time.  These processes are capable of using a DB function to Drop the partition, which quickly removes the data from the cube, rather than having to run a resource intensive Delete query.  This only happens if you deletion/archiving criteria is set to remove an entire partition of data.
    Again - review the other threads on the BI forums on Partitioning.  Most questions you have will already have been asked and answered before, and post again on SDN if there is something you still have a question about.

  • How to know whether a TCode is called directly or not

    Hi all,
    I have a requirement to create a popup in a standard TCode. This TCode is recorded to BDC and used in another report.
    I would like to know how we can check (in code) whether the standard Tcode is being called directly or it is being called by a different program, function module or bdc ...
    Thanks,
    Khanh
    Edited by: Khanh Nguyen on Apr 1, 2010 4:37 PM

    Hi,
    It can be checked in the following way:
    IF sy-calld IS INITIAL.     
    ENDIF.
    " sy-called is initial if the program is run stand alone. If it called from another program, it is not initial.
    Thanks & Regards
    Rocky Agarwal

  • How to know whether my iphone 5 imei replaced or not???

    Please help

    Where did you get it? In some (not all) countries, it is possible to purchase unlocked phones directly from Apple. Some carriers in some countries sell unlocked phones. Some carriers in some countries offer unlocking of iPhones.

  • How to know whether entered date is SAPdate format or User dateformat.

    Hi all,
    I am uploading data from SAP to internal table  ,
    here I need to do below logic ,
    If user entered SAP dateformat in excel , no  need to convert after uploading.
    elseIf user entered user default need to convert to SAP date format.
    If user entered in other foramt.
    need to give error.
    so , how to know whether entered data is in SAP format or not.
    Regards,
    vinesh

    Try this logic
    IF call fm DATE_CHECK_PLAUSIBILITY = true
       "date etered in SAP internal format
    ELSE if call fm CONVERT_DATE_TO_INTERNAL = true
       "date entered in user format
    else.
      "incorrect format
    endif.
    Regards
    Marcin

  • How to know whether my Windows Phone 8.1 App is Associated with the store or not?

    How to know whether my Windows Phone 8.1 App is Associated with the store or not? 
    I have an Windows Phone 8 app already in the store , Now i upgraded it to 8.1 it got upgraded to Windows Phone Silverlight 8.1.
    Now iam trying to use Single Sign on feature on this app but it is showing the error message like
    the App is not Configured correctly i followed the process from  Signing users in to OneDrive
    please guide me how to do this?
    Mohan Rajesh Komatlapalli

    You should post to publish forum.

  • How to know whether the javascript is disabled or not while loading the jsp

    Hi,
    My query is like how to know whether the javascript is disabled or not while loading the Application main JSP in Mozilla browser.
    I want some Java code or JavaScript code.

    To the point, just let JS fire a specific HTTP request inside the same session.
    This can be done in several ways. 1) Create a hidden <img> element and set the `src` attribute so that it will request a (fake) image from the server. The server just have to intercept on this specific request. 2) Fire an ajaxical request and let the server intercept on it. You can use a Filter for this which sets a token in the session scope to inform that the client has JS enabled.

  • How to know whether a method is thread-safe through the java-doc?

    In some book, it says that SAXParserFactory.newSAXParser() is thread-safe,but in the java-doc,it doesn't say that.
    newSAXParser
    public abstract SAXParser newSAXParser()
    throws ParserConfigurationException,
    SAXExceptionCreates a new instance of a SAXParser using the currently configured factory parameters.
    Returns:
    A new instance of a SAXParser.
    Throws:
    ParserConfigurationException - if a parser cannot be created which satisfies the requested configuration.
    SAXException - for SAX errors.
    I want to know, how to know whether a method is thread-safe?

    System.out is a PrintStream object. None of the methods there use the synchronized modifier, but if you look in the source code, you will find out it is thread-safe, because it will use synchronized blocks whenever it writes some text.
    The source code is in the src.jar file which you can extract.
    I didn't find any comments about that PrintStream is thread-safe in the API.

  • How to know whether the Content Type at Library level is Inheriting Parent Content type or not Using Powershell?

    Hi,
    How to know whether the Content Type at Library level is Inheriting Parent Content type or not using Powershell?
    Is there any property for that? Or Do I need to compare the Content type Id's at Site collection level and Library level?
    Any help would be greatly appreciated.
    Thank you,
    AA.

    Hi Ashok,
    For a content type, there is an attribute called Inherits, the value of this attribute determines whether the content type inherits fields from its parent content type when it is created.
    If Inherits is TRUE, the child content type inherits all fields that are in the parent, including fields that users have added.
    If Inherits is FALSE or absent and the parent content type is a built-in type, the child content type inherits only the fields that were in the parent content type when SharePoint Foundation was
    installed. The child content type does not have any fields that users have added to the parent content type.
    More information, please refer to the link:
    https://msdn.microsoft.com/en-us/library/office/aa544268.aspx?f=255&MSPPError=-2147217396
    Best Regards,
    Wendy
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • How to know whether the current database is using a password file or not?

    How to know whether the current database is using a password file or not?

    The remote_password_file is the parameter that determines if you can use or not a password file. The values this parameter can have are NONE, SHARED, EXCLUSIVE. It is pretty obvious, if it is set to either SHARED or EXCLUSIVE the oracle instance has enabled the access through a password file for the SYSDBA and SYSOPER roles.
    ~ Madrid

  • How to know whether database(oracle) is up and running at OS level

    how to know whether database(oracle) is up and running at OS level...!!!

    depends on the O/S you are using, Unix or Windows? I would use Korn shell script to monitor the Oracle background process and scripts to check of Oracle is accepting connections.
    This UNIX command will show the number of processes for your instance:
    ps -ef|grep $ORACLE_SID|grep -v grep|grep -v ora_|wc u2013l
    In Windows I would look into services.msc

  • How to know whether a connection leak occured in weblogic8.1

    How to Know whether Conenction Leak has Occured or Not ??..Where does the WeblogicServer8.1 print the STACK TRACE if connection Leak has occured ? or does it maintain a LOG FILE , where any entries can be seen................

    To turn on Debug flags add these to the startup scripts.
    -Dweblogic.Debug=weblogic.JDBCConn="true",weblogic.JTAJDBC="true"
    Essentially, you will need to edit the config.xml file (when the server is down) and add the proprty to the ConnectionPool definition:
    http://e-docs.bea.com/wls/docs61/config_xml/mbeans.html
    ConnLeakProfilingEnabled="true"
    Thanks and regards,
    Pazhanikanthan. P

Maybe you are looking for

  • Just downloaded itunes 11.1 and when i click on the store its a blank screen

    I have just downloaded itunes 11.1 and now when I try to open up the itunes store it just comes up blank with nothing showing. No songs or new albums or anything on the itunes store. I have no idea whats wrong and I have tried closing itunes on my co

  • HT5429 Has anyone reported a problem on iOS 6 Maps and had it fixed?

    Within iOS 6 maps, I reported that searching for Holland Park underground station in London yields two locations for the station (one of them being wrong). It has been over three weeks and the issue has not been corrected.

  • Data in internal table.

    hi, i have one internal table in that 4 records. f1 f2 f3 f4 1 20 25 35 2 49 25 45 3 50 35 50 4 69 35 70 in this f3 values r repeating i want only one record means i want oout put like 1 20 25 35 3 50 35 50 pls send me code

  • N 97 : poor performance & Pathetic service

    Hello,   I have been a happy Nokia Customer and have owned several Nokia products for last 12 years. I have run into a series of problems after buying Nokia N97 (Product code:RM505, Seller : Hot Spot GIP Opp Sec-18, Noida, Invoice No:376, Dated 04.08

  • Form scrambled in Firefox

    I have a fillable form on our website.  It works fine in Chrome and IE.  However, if I click on the form's link in Firefox, I get a mess and a message at the top that says "This PDF document might not be displayed correctly". And the option to open i