And if I attempt to decrypt in ColdFusion what I've encrypted in 
Flex, I got:
An error occurred while trying to encrypt or decrypt your input 
string: com.rsa.jsafe.crypto.dr: Could not perform unpadding: 
invalid pad byte.. 

It would be great if you can help me out.  All I need to do is 
encrypt it so that CF can decrypt it.
Thanks in advance.

--- In [email protected], "ivansebastiansurya" 
<[EMAIL PROTECTED]> wrote:
>
> Hi,
> 
> Thanks for your help,
> 
> But I still got different result for encrypting in Flex using the 
> crypto library:
> 
> var key:ByteArray = Hex.toArray
("4cb3c6af71194975d7a7679635c44517");
> var cipher:ICipher = Crypto.getCipher("aes", key);
> var rawData:ByteArray = Hex.toArray(Hex.fromString("This is a 
> Test")); // I suppose you convert the string to hex first, then to 
>          // byte array.
> cipher.encrypt(rawData);
> ti_encodedText.text = Hex.fromArray(rawData); // to print it out,
>  // need to convert it to hex string first???
> 
> This gives me: 28c8f58f6858ea48ed85c88fb2a5fd69
> 
> But in ColdFusion below:
> 
> <cfset HexKey = "4cb3c6af71194975d7a7679635c44517">
> <cfset myKey = ToBase64(BinaryDecode(HexKey, "Hex"))>
> 
> <cfset PlainText = "This is a Test">
> <Cfset Encrypted = Encrypt(PlainText, MyKey, 'AES','Hex')>
> <Cfset Decrypted = Decrypt( Encrypted, MyKey, 'AES','Hex')>
> 
> <cfoutput>
> Hex Key: #HexKey#<br />
> Key: #MyKey#<Br>
> 
> Plain Text: #PlainText#<br>
> Encrypted: #Encrypted#<Br>
> Decrypted: #Decrypted#<br>
> </cfoutput>
> 
> The encrypted text is  14C561515CA3283C297EEC0A99E80D08
> 
> So I got different result for encrypting the same text using the 
> same key.
> 
> Do you have any idea why this is the case?
> 
> Thanks,
> 
> Ivan.
> --- In [email protected], Jeffry Houser <jeff@> wrote:
> >
> > 
> >   By Crypto I meant the AS3 library you link to, which is 
> named "As3 
> > Crypto".  I'm pulled up my code.
> > 
> >   You should be able to use the CryptoDemo to create a Key in 
> Hex.  Once 
> > you have the key, you should be able to do something like this 
in 
> CF:
> > 
> > <cfset HexKey = "8738fed68e7677d374e0946c8f7bd3bb">
> > <cfset myKey = ToBase64(BinaryDecode(HexKey, "Hex"))>
> > 
> > <cfset PlainText = "This is a Test">
> > <Cfset Encrypted = Encrypt(PlainText, MyKey, 'AES','Hex')>
> > <Cfset Decrypted = Decrypt( Encrypted, MyKey, 'AES','Hex')>
> > 
> > <cfoutput>
> >   Hex Key: #HexKey#<br />
> >   Key as string: #hexToString(HexKey)#<Br>
> >   Key: #MyKey#<Br>
> >     
> >   Plain Text: #PlainText#<br>
> >   Encrypted: #Encrypted#<Br>
> >   Decrypted: #Decrypted#<br>
> > </cfoutput>
> > 
> > 
> >   You'll probably want something a bit more 'dynamic' but 
> hopefully this 
> > will get you going.  I haven't looked at it in months, so the 
code 
> is 
> > not fresh in my mind...
> > 
> > 
> > 
> > ivansebastiansurya wrote:
> > > 
> > > 
> > > Crypto? You mean ColdFusion?
> > > Seems like I can't decode the encoded string.
> > > Thanks.
> > > 
> > > I use the library at http://crypto.hurlant.com/ 
> <http://crypto.hurlant.com/>
> > > Thanks,
> > > 
> > > Ivan.
> > > 
> > > --- In [email protected] <mailto:flexcoders%
> 40yahoogroups.com>, 
> > > Jeffry Houser <jeff@> wrote:
> > >  >
> > >  >
> > >  > Which library?
> > >  >
> > >  > I've been able to successfully pass data back and forth 
> between
> > > Flex
> > >  > and Crypto using AES.
> > >  >
> > >  > There are settings you need to specify (128 bit 
something?), 
> but
> > > w/o
> > >  > pulling the code, I don't remember them.
> > >  >
> > >  > ivansebastiansurya wrote:
> > >  > >
> > >  > >
> > >  > > Hi there,
> > >  > >
> > >  > > Has anyone attempted to encode some string in Flex and 
> decode it
> > > in
> > >  > > COldFusion?
> > >  > > I've attempted to encode the string using the library in
> > >  > > http://crypto.hurlant.com/ <http://crypto.hurlant.com/> 
> > > <http://crypto.hurlant.com/ <http://crypto.hurlant.com/>>
> > >  > > as follows:
> > >  > > var key:ByteArray = Hex.toArray(model.hashKey); // some 
key
> > >  > > var cipher:ICipher = Crypto.getCipher("aes", key);
> > >  > > var rawData:ByteArray = Hex.toArray(dataToEncrypt);
> > >  > > I then send the encrypted data as a string (Hex.fromArray
> > >  > > (encryptedByteArray).
> > >  > >
> > >  > > I then try to decrypt it in ColdFusion, using:
> > >  > > decrypted=decrypt(arguments.xmlString,
> > >  > > application.hashkey, "AES", "Hex");
> > >  > >
> > >  > > , but it doesn't seem to work.
> > >  > >
> > >  > > If anyone can help me out, that would be greatly 
> appreciated.
> > >  > > Thanks,
> > >  > >
> > >  > > Ivan.
> > >  > >
> > >  > >
> > >  >
> > >  > --
> > >  > Jeffry Houser, Technical Entrepreneur, Software Developer, 
> Author,
> > >  > Recording Engineer
> > >  > AIM: Reboog711 | Phone: 1-203-379-0773
> > >  > --
> > >  > My Company: <http://www.dot-com-it.com <http://www.dot-com-
> it.com>>
> > >  > My Podcast: <http://www.theflexshow.com 
> <http://www.theflexshow.com>>
> > >  > My Blog: <http://www.jeffryhouser.com 
> <http://www.jeffryhouser.com>>
> > >  >
> > > 
> > > 
> > 
> > -- 
> > Jeffry Houser, Technical Entrepreneur, Software Developer, 
Author, 
> > Recording Engineer
> > AIM: Reboog711  | Phone: 1-203-379-0773
> > --
> > My Company: <http://www.dot-com-it.com>
> > My Podcast: <http://www.theflexshow.com>
> > My Blog: <http://www.jeffryhouser.com>
> >
>


Reply via email to