problem during decryption of password encrypted

Hello to all that I am saving the password encrypted in the database. And decrypting the password attached to the url. But while I'm decrypting it gives me the Exception BadPadding exception. I used this class to encrypt and decrypt the password.

public class CryptAes {

    // First create the AES key based on the bytes in secretKey using  keyLength bits as the length
    static AESKey keydec = new AESKey("A3$1E*81234567891111111111111111".getBytes() );
    static AESKey keyenc = new AESKey("A3$1E*81234567891111111111111111".getBytes() );
    static AESKey keyenc128 = new AESKey("A3Q1EF8123456789".getBytes());
    static AESKey keydec128 = new AESKey("A3Q1EF8123456789".getBytes());

    private static byte[] iv = { 0x0a, 0x01, 0x02, 0x03, 0x04, 0x0b, 0x0c,
        0x0d, 0x0a, 0x01, 0x02, 0x03, 0x04, 0x0b, 0x0c, 0x0d };

    public static byte[] plainText= new byte[10000];

 public static String AESEncryption(byte[] plainText) {

        String resultString = null;

        try {

             AESEncryptorEngine engine = new AESEncryptorEngine( keyenc128 );

             CBCEncryptorEngine cengine=new CBCEncryptorEngine(engine, new InitializationVector(iv));
                PKCS5FormatterEngine fengine = new PKCS5FormatterEngine( engine );
                ByteArrayOutputStream output = new ByteArrayOutputStream();
                BlockEncryptor encryptor = new BlockEncryptor( fengine, output );

                encryptor.write(plainText);
                encryptor.close();
                byte[] encryptedData = output.toByteArray(); output.close();
                String st=new String(encryptedData);

                byte[] base64 = Base64OutputStream.encode(encryptedData, 0, encryptedData.length, false, false);

                      //Base64Coder.encodeString(Byte.toString(plainText));
                      resultString = new String(base64);

        } catch (CryptoException cryptoException) {
            // TODO: handle exception
            System.out.println("Exception is "+cryptoException.getMessage()+"And the exception is"+cryptoException.toString());
        }
        catch (CryptoTokenException e) {
            // TODO: handle exception
            System.out.println("Exception is "+e.getMessage()+"And the exception is"+e.toString());
        }catch (CryptoUnsupportedOperationException e) {
            // TODO: handle exception
            System.out.println("Exception is "+e.getMessage()+"And the exception is"+e.toString());
        }catch (IOException e) {
            // TODO: handle exception
            System.out.println("Exception is "+e.getMessage()+"And the exception is"+e.toString());
        }
        return resultString;
  }

    public static String AESDecryption(byte[] cipherText, int dataLength ) /*throws CryptoException, IOException, CryptoTokenException, CryptoUnsupportedOperationException*/ {      

        String reString = null;
        try {

            ByteArrayInputStream in = new ByteArrayInputStream( cipherText, 0, dataLength );

            // Now create the block decryptor and pass in a new instance
            // of an AES decryptor engine with the specified block length
            BlockDecryptor cryptoStream = new BlockDecryptor(new AESDecryptorEngine( keydec128 ), in );
            byte[] T = new byte[dataLength];

            // Read the decrypted text from the AES decryptor stream and
            // return the actual length read        

            int length = cryptoStream.read( T ); //Here i am getting exception BadPadding
            reString = new String(T);
            int i=reString.indexOf("");
            reString = reString.substring(0,i+6);      

        } catch (CryptoException e) {
            // TODO: handle exception
            System.out.println("Exception is ="+e.getMessage());
        }catch (CryptoTokenException e) {
            // TODO: handle exception
            System.out.println("Exception is ="+e.getMessage());
        }catch (CryptoUnsupportedOperationException e) {
            // TODO: handle exception
            System.out.println("Exception is ="+e.getMessage());
        }catch (IOException e) {
            // TODO: handle exception
            System.out.println("Exception is ="+e.getMessage()+"333333333333"+e.toString());
        }
        // Create the input stream based on the ciphertext        

        return reString;

    }

Help me with this.

I was trying to encrypt and decipher passing on it but only has failed, so I just change how to encrypt or to decrypt the password. I had just use Base64Coder class to achieve this. And thank you for your concern. And here is the Base64Coder class, if someone needs it.

//Copyright 2003-2009 Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland
//www.source-code.biz, www.inventec.ch/chdh
//
//This module is multi-licensed and may be used under the terms
//of any of the following licenses:
//
//EPL, Eclipse Public License, http://www.eclipse.org/legal
//LGPL, GNU Lesser General Public License, http://www.gnu.org/licenses/lgpl.html
//AL, Apache License, http://www.apache.org/licenses
//BSD, BSD License, http://www.opensource.org/licenses/bsd-license.php
//
//Please contact the author if you need another license.
//This module is provided "as is", without warranties of any kind.

/**
* A Base64
* r/Decoder.
*
* 

* This class is used to encode and decode data in Base64 format as described in RFC 1521. * *

* Home page: http://www.source-code.biz">www.source-code.biz
* Author: Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland
* Multi-licensed: EPL/LGPL/AL/BSD. * *

* Version history:
* 2003-07-22 Christian d'Heureuse (chdh): Module created.
* 2005-08-11 chdh: Lincense changed from GPL to LGPL.
* 2006-11-21 chdh:
*   Method encode(String) renamed to encodeString(String).
*   Method decode(String) renamed to decodeString(String).
*   New method encode(byte[],int) added.
*   New method decode(String) added.
* 2009-07-16: Additional licenses (EPL/AL) added.
* 2009-09-16: Additional license (BSD) added.
*/ public class Base64Coder { //Mapping table from 6-bit nibbles to Base64 characters. private static char[] map1 = new char[64]; static { int i=0; for (char c='A'; c<='Z'; c++) map1[i++] = c; for (char c='a'; c<='z'; c++) map1[i++] = c; for (char c='0'; c<='9'; c++) map1[i++] = c; map1[i++] = '+'; map1[i++] = '/'; } //Mapping table from Base64 characters to 6-bit nibbles. private static byte[] map2 = new byte[128]; static { for (int i=0; iin. * @return A character array with the Base64 encoded data. */ public static char[] encode (byte[] in, int iLen) { int oDataLen = (iLen*4+2)/3; // output length without padding int oLen = ((iLen+2)/3)*4; // output length including padding char[] out = new char[oLen]; int ip = 0; int op = 0; while (ip < iLen) { int i0 = in[ip++] & 0xff; int i1 = ip < iLen ? in[ip++] & 0xff : 0; int i2 = ip < iLen ? in[ip++] & 0xff : 0; int o0 = i0 >>> 2; int o1 = ((i0 & 3) << 4) | (i1 >>> 4); int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6); int o3 = i2 & 0x3F; out[op++] = map1[o0]; out[op++] = map1[o1]; out[op] = op < oDataLen ? map1[o2] : '='; op++; out[op] = op < oDataLen ? map1[o3] : '='; op++; } return out; } /** * Decodes a string from Base64 format. * @param s a Base64 String to be decoded. * @return A String containing the decoded data. * @throws IllegalArgumentException if the input is not valid Base64 encoded data. */ public static String decodeString (String s) { return new String(decode(s)); } /** * Decodes a byte array from Base64 format. * @param a Base64 String to be decoded. * @return An array containing the decoded data bytes. * @throws IllegalArgumentException if the input is not valid Base64 encoded data. */ public static byte[] decode (String s) { return decode(s.toCharArray()); } /** * Decodes a byte array from Base64 format. * No blanks or line breaks are allowed within the Base64 encoded data. * @param in a character array containing the Base64 encoded data. * @return An array containing the decoded data bytes. * @throws IllegalArgumentException if the input is not valid Base64 encoded data. */ public static byte[] decode (char[] in) { int iLen = in.length; if (iLen%4 != 0) throw new IllegalArgumentException ("Length of Base64 encoded input string is not a multiple of 4."); while (iLen > 0 && in[iLen-1] == '=') iLen--; int oLen = (iLen*3) / 4; byte[] out = new byte[oLen]; int ip = 0; int op = 0; while (ip < iLen) { int i0 = in[ip++]; int i1 = in[ip++]; int i2 = ip < iLen ? in[ip++] : 'A'; int i3 = ip < iLen ? in[ip++] : 'A'; if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127) throw new IllegalArgumentException ("Illegal character in Base64 encoded data."); int b0 = map2[i0]; int b1 = map2[i1]; int b2 = map2[i2]; int b3 = map2[i3]; if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0) throw new IllegalArgumentException ("Illegal character in Base64 encoded data."); int o0 = ( b0 <<2) | (b1>>>4); int o1 = ((b1 & 0xf)<<4) | (b2>>>2); int o2 = ((b2 & 3)<<6) | b3; out[op++] = (byte)o0; if (op

Tags: BlackBerry Developers

Similar Questions

  • Able to decrypt the passwords to oracle, a security problem?

    Hello
    Before all sorry if this is a silly question. I'm still fairly new to Oracle...

    My company is using Toad for Oracle to access our database, now I found a thread on the internet saying there is a tool that allows to decrypt the passwords to oracle.
    How can we prevent someone from our database passwords decryption?

    Thread of the example: http://toadfororacle.com/thread.jspa?threadID=36841

    Is it a security issue?

    Thank you
    Dere

    Published by: user6032647 on 05/04/2012 22:12

    The way I read it is that TOAD stores Oracle connection details in an .ini file, and this file can be decrypted.

    Oracle does not store the encrypted passwords, it stores the hashed passwords that cannot be decrypted. If the hashes are exposed they can be brute-force, so the complex passwords are essential.

    It is a problem of TOAD. Connection passwords should not be saved (I guess that TOAD a standard Windows "save my password checkbox", it were not used for years). If it is used as a mechanism to hide the users of TOAD database connection details, then serious consideration of safety is required.

    Dave

  • Remote Desktop Connection Manager v2.2 - "Unable to decrypt the password"

    Hello
    I have a problem with RDCM. When I log in as an administrator I can access the servers without any problem. Things get complicated when I try to do as a user. Then I get this message:

    Impossible to decrypt the password

    I want users to connect by using their usernames and passwords, but I also want that they have access to all servers. How can I do?

    Hello

    Please contact Microsoft Community.

    The problem you are having is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for the IT Pro TechNetpublic.

    Please post your question in the TechNet Forum.

    https://social.technet.Microsoft.com/forums/WindowsServer/en-us/home?Forum=winRDc

    Hope this helps you solve the problem, if any question you can write us and we will be happy to help you further.

  • Hidekeys with password encryption Service

    Hello

    I'm reviewing my companies switch check-in facility and I noticed was the lack of the "hidekeys" command in the configuration of archive. I wonder if this is really necessary when the service password encryption is enabled as surely all passwords would be encrypted anyway?

    Thank you!

    "the password encryption service" is a very weak security measure because it is reversible. The algorithm is documented and anyone sniffing the transfer can restore passwords. Thereby, these passwords must be viewed in plain text. Now you have to decide if this is a problem for your environment.

    Best practice is to move the hashed passwords, where possible. For the fair user accounts move to the 'secret' of the configuration form. But for all types of routing-protocol-passwords which is not possible.

  • How to decrypt the password in a mapping of WSConnector/SOA?

    Hello

    How can I decrypt password of the user in the SOA? Now I map the field of password on the other side of CreateOp_InputVariable (/ ns2: create/userAccount/__PASSWORD__) in the password field of the my WS of application in the component of the entitlement and this password is encrypted in the WS request too. But I need clear form of password here. How can I do?

    Is it possible to make a transformation/decryption of password in SOA (in the WSConnector.bpel)?

    The payload of the WSConnector are:

    < input >

    < InvokeCreate_vytvorPouzivatela_InputVariable >

    < name of part = 'Settings' >

    < vytvorPouzivatela >

    < idVolajuceho > XYZ11111 < / idVolajuceho >

    < user >

    < aktivny > true < / aktivny >

    < heslo >zRUIc60NAqg/Gh5D4QerihmAZHu7XspxVkj3KPvwlJY =< / heslo >

    < idmKod > TE510001 < / idmKod >

    < idmKodOrganizacie > 11010084000 < / idmKodOrganizacie >

    < connection > TE510001 < / login >

    < meno > Test < / meno >

    < priezvisko > user < / priezvisko >

    < pristupy >

    < rolePriznak > RIS < / rolePriznak >

    < / pristupy >

    < / user >

    < / vytvorPouzivatela >

    < / part >

    < / InvokeCreate_vytvorPouzivatela_InputVariable >

    < / Entry >

    As you can see, the password is encrypted and I need a clear form by the password (password is placed between the tags < heslo > < / heslo >). BTW, I'm not able to edit the Web Services application so I need to solve my site.

    Thank you.

    Milan

    Try adding a string in build.xml (I like my third line)

    This requires ant - contrib.jar in the folder $ANT_HOME/lib. So if you do not find in $MW_HOME and copy to the folder I mentioned.

  • Tracking package to decrypt the password for EBS

    Hello

    There are methods where we can decrypt the password of EBS by using some packages.

    My question is there any method that we can follow whether or not this package has been used by sending a warning to dba. I'm afraid that somehow the developers on my team running this package to decrypt the password for the Apps or Sysadmin.

    EBS 11.5.10.2
    DB 11.2.0.2

    Thank you
    Vicky

    1. you must use passwords in your instance DEV who differ from the PROD, and also to hide any sensitive data. This will reduce the problem is that a lot of people have the APPS or SYSADMIN passwords (legitimately or not)

    2. If the developers have permissions to use the API to decrypt the passwords, so they probably also permissions to create packages that will make it more difficult to follow. You must therefore ensure that the developers have only the permissions required for them to do their job

    3 oracle has long recommended implementing non-reversible hash password system to enhance the security of password FND_USER
    Note 457166.1 : new feature of the utility FNDCPASS: improving security by Non-reversible hash password

    This applies to both version 11i and Release 12

    Hope this helps

    concerning

    Mike

  • Password encrypt a PDF file. (security lost)

    Hello

    I use the following piece of code password encrypt a PDF file

    However. When I copy this PDF file to another machine. the PDF is not secure

    Help, please... It is very important to me.

    char * errorBuf;

    DURING THE
    CString strPassword = "123456789";
    PDDocSetNewCryptHandler (pdDoc, ASAtomFromString ("Standard"));
    StdSecurityData securityData = (StdSecurityData) PDDocNewSecurityData (pdDoc);
    securityData-> format = sizeof (StdSecurityDataRec);
    securityData-> hasUserPW = false;
    securityData-> newOwnerPW = false;
    securityData-> hasOwnerPW = true;
    securityData-> newOwnerPW = true;
    strcpy_s (securityData-> ownerPW, strPassword);
    strcpy_s (securityData-> userPW, strPassword);
    securityData-> perms = pdPermPrint;

    securityData-> keyLength = 16;
    PDDocSetNewSecurityData (pdDoc, securityData (void *));
    PDDocSetFlags (pdDoc, PDDocRequiresFullSave);

    HANDLER
    ASGetErrorString (ASGetExceptionErrorCode(), errorBuf, 255);
    AVAlertNote (errorBuf);
    END_HANDLER

    Have you thought to save the PDF file after execution of this?  This gives him only to be guaranteed - you still need to save it.

  • On the remote host MySQL database: password encryption?

    Hello

    I discovered the world of PHP and MySQL in the last days. I didn't get all the intricacies still but nevertheless I managed to set up a server "localhost" on my computer, create a MySQL database and display correctly information in this database in HTML using PHP pages.

    I am now at the stage of transferring it to the remote host where the site will happen: I exported my database, imported these information in the database on the server host and I n unexpectedily even just to get my PHP/HTML pages to connect to this database. It's great.

    I have one question. I've read a lot of thread in this forum about this, but haven't seen an answer: must the password encryption? I mean, when I connect to a database using DW CS4, the software creates for me a connections folder in my Web site root folder and stores inside a little PHP to the folder with the server name, database name, user name and password which are necessary to allow PHP to connect to the MySQL database. It is all printed clearly in there. Once which is transferred to the remote host, it is always accessible to anyone? Should I not worry and try to hide the password?

    Any thoughts on this would be greatly appreciated.

    Emilie

    Thread moved to Dreamweaver application development forum, which addresses other issues aside and PHP/MySQL server.

    As long as the server is enabled in PHP, put the connection details in a PHP file like this is not a problem. PHP code is processed on the server. Only its output is sent to the browser. Even if someone guesses the name of your connection file, they won't see anything if they try to load the page in a browser. The only way they can see it is to hack into the server. It is important to have passwords on your FTP account.

  • Insert the password encrypted in the table user = &gt; ORA-01861

    Hello

    I have a little problem, I try to save a password encrypted in the user's my table:

    It works well:
    declare
    test VARCHAR2(40);
    begin
    select RAWTOHEX(dbms_crypto.hash(utl_raw.cast_to_raw('yyyyyyy'), dbms_crypto.hash_sh1)) into test from dual;
    DBMS_OUTPUT.PUT_LINE(test);
    end;
    /
    But when I try to integrate it into a procedure to insert in my table of the user, it shows me an error ORA-01861:
    create or replace procedure inserer_utilisateur(v_nom in varchar2, v_prenom in varchar2, v_adresse in varchar2, v_mail in varchar2, v_login in varchar2, v_password in varchar2, v_dateNaissance in date) as
        id_uti integer;
        id_duti integer;
    begin
        select seq_Utilisateur.nextval into id_uti from dual;
        insert into Utilisateur values (id_uti,v_nom,v_prenom,v_adresse,v_mail,v_login,RAWTOHEX(dbms_crypto.hash(utl_raw.cast_to_raw(v_password), dbms_crypto.hash_sh1)),to_date(v_dateNaissance,'DD-MM-YYYY'));
        select seq_Droit_Utilisateur.nextval into id_duti from dual;
        insert into Droit_Utilisateur values (id_duti,id_uti,1); 
    end;
    The procedure is called from my APEX application, it works when I don't encrypt the password.

    I forgot something?

    Thank you.

    Yann.

    The problem has nothing to do with encryption

    The v_dateNaissance parameter is a date, remove the TO_DATE at all:

    insert into Utilisateur values (id_uti,v_nom,v_prenom,v_adresse,v_mail,v_login,RAWTOHEX(dbms_crypto.hash(utl_raw.cast_to_raw(v_password), dbms_crypto.hash_sh1)),v_dateNaissance);
    

    Max
    http://oracleitalia.WordPress.com

    Published by: Massimo Ruocchio, February 16, 2010 18:43

  • I NEED HELP Please im having a problem to forget my password and when I plug it it says its locked with a password he try to put the itunes thing but

    NEED HELP Please im having a problem to forget my password and when I plug it it says its locked with a password he tried to put the itunes thing but it says enter password I put in what I rember, then said lokced for five minutes help me pls

    Without knowing the password for your iPhone, there is no way to unlock it, bring even you to the Genius Bar. If you continue to enter the wrong password, you will be locked out of your iPhone, and your data will be unaccessable.

  • Password encrypted ticket to principal-protected or is security authorization simply in function?

    Result, the safety of this new feature of file system permissions, or are password encrypted notes?

    I think that it has encrypted - Security iCloud and overview of privacy - Apple Support

  • Can't backup windows because Backup has encountered a problem during backup of the C:\Users\marcel\Documents\Youcam file. Error: (the system cannot find the specified file. (0 x 80070002))

    can not backup windows because: Backup has encountered a problem during backup of the C:\Users\marcel\Documents\Youcam file. Error: (the system cannot find the specified file. (0 x 80070002))
    Backup has encountered a problem during backup of the C:\Users\marcel\Documents\Youcam file. Error: (the system cannot find the specified file. (0 x 80070002)).

    Maybe it's because I disabled the camera to prevent other people using the computer?

    [Moved from comments]

    Hi Marrcel,

    Thank you for keeping us posted.

    The issue can be due to turning the camera off. I suggest you to activate the camera and try.

    Please come back for any clarification on this or any issue of Windows. We will be happy to help you.

  • When you save the playlist, error - "Windows Media Player has encountered a problem during the creation or recording of the reading list.".

    When I try to save a playlist, I get an error message "Windows Media Player has encountered a problem during the creation or recording of the reading list.".

    Hello

    • Will there be any changes made prior to this issue?
    • What version of Windows are you using?

    Step 1: I recommend to run the Windows Media Player settings Troubleshooter and check.

    http://Windows.Microsoft.com/en-us/Windows7/open-the-Windows-Media-Player-settings-Troubleshooter

    Step 2: If the problem is to uninstall and reinstall Windows Media Player. Here's how.

    Uninstalling and reinstalling Windows Media Player:

    (A) uninstall Windows Media Player:

    a. go to start and in the search type 'Turn Windows has or not'.

    b. click on "Turn Windows features on or off".

    c. find multimedia and uncheck the brand in the face of Windows Media Player.

    d. restart the computer

    (B) reinstall Windows Media Player:

    a. go to start and in the search type 'Turn Windows has or not'.

    b. click on "Turn Windows features on or off".

    c. find the multimedia functions and place a check mark in front of the Windows Media Player.

    d. restart the computer.

    For more information, see the article below:

    http://Windows.Microsoft.com/en-us/Windows7/turn-Windows-features-on-or-off

  • There was a problem playing this file. (0xC00D0FEA: "Windows Media Player has encountered a problem during the download of the file.) For any additional help, click Help on the Web. »)

    Outlook has been changed from hotmail, my emails say don't link with windows media player, outlook is not their problem, but it happened only when they merged account

    I have to be able to open MP3 files that ae sent emails in my work, it's urgent, please I need to know what settings to correct to sort this please

    It comes to getting the error message

    There was a problem playing this file. (0xC00D0FEA: "Windows Media Player has encountered a problem during the download of the file.) For any additional help, click Help on the Web. »)

    E-mail address is removed from the privacy *.

    Hello

    Method 1:

    See the article and check if that helps:

    Windows Media Player sync: frequently asked questions

    http://Windows.Microsoft.com/en-us/Windows-Vista/Windows-Media-Player-sync-frequently-asked-questions

    Method 2:

    I suggest also refer to the thread with a similar problem and a possible solution:

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_vista-pictures/error-when-trying-to-play-media-files-Windows/4abe7be7-b3fe-44eb-b4da-e0848c3c8bd4

    It will be useful.

  • I have problem on my bios password

    I have problem on my bios password I putt 3 times now its stopped with error cnu938516w

    To try.

    e9lofuq3gd

    3rd letter tiny L.

    4th letter lowercase O.

    7th letter lowercase Q.

    Use this code to go into the BIOS.

    Disable all passwords that are enabled.

    If demand for CURRENT password using this code.

    Request NEW password just press ENTER.

    If asked to hit just to CHECK password to enter.

    Save and exit.

    REO

    I must inform you that these services are not endorsed by HP, and that HP is not responsible for any damages that may occur to your system using these services. Please be aware that you do so at your own risk.

Maybe you are looking for

  • Need warranty information?

    My cell phone is broken and I was wondering what they in fact will replace it with if it is not repairable, is it up to the value he bought or something of the similar specifications?

  • Re: Satellite m30 - 404 only standard installed driver windows

    Hello I have a M30-404 and I had problems with the graphics (nvidia GeForceTM FX Go5200) driver. The interface works very well with the standard vga driver in windows, but when I install the driver nvidia screen remains black. Sometimes, you see the

  • Font too small to read AOL mailbox

    Have a new Dell, monitor 24 "with Windows 7 Professional.  Downloaded AOL 9.5.  Works fine except that the police of the mailbox is too small to read - not the message content but the list messages.  Windows 7 allows to enlarge the fonts to 150%, to

  • How in Simulator bb10 take screenshots of tested App?

    How in Simulator bb10 [VM PLAYER] take screenshots of tested App? location needed to use the maps, how to add my application accepted after the active GPS?

  • SG 300-10 mp - cannot open a session in any router does not respond

    Newly purchased SG300. Got the updated firmware updated, the user name and new password entered. Started lends itself to configure the switch for the first time this morning and my browser expires every time that I try 192.168.1.254. IPconfig is no h