Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Encryption using Tea algorithm (New Variant)

by mkirank (Chaplain)
on Jan 17, 2006 at 09:57 UTC ( #523709=perlquestion: print w/ replies, xml ) Need Help??
mkirank has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
Is it possible to use Crypt::Tea_JS.pm to encrypt a string using TEA (Tiny Encryption Algorithm) (New Variant) .
It says in the Tea_JS documentation that
Crypt::Tea_JS uses the New Improved version of the TEA .
but I could not find anything on how to use the same (encrypt method of Tea_JS uses CBC).

When I use the java program TEAV.java and encrypt the string "hello world" I get an output "60350EDF4F87A541C216C4BE5C50D7AD" Encoded as Hex string
using the key "0123456789ABCDEF0123456789ABCDEF".

Can I do the same encryption using Crypt::Tea_JS,
If that is possible please let me know how to use the API to do the same .
Thanks

Comment on Encryption using Tea algorithm (New Variant)
Re: Encryption using Tea algorithm (New Variant)
by marto (Chancellor) on Jan 17, 2006 at 10:08 UTC
    mkirank,

    Did you read the documentation and try any of the examples?
    Often the easiest way to find out if you can do something is to try it.

    "I could not find anything on how to use the same (encrypt method of Tea_JS uses CBC). "

    From the documentation:

    "encrypt( $plaintext, $key ); Encrypts with CBC (Cipher Block Chaining)"


    I can't install this module at the moment, try an short example program like:
    #!/usr/bin/perl use strict; use warnings; use Crypt::Tea_JS; my $key = '0123456789ABCDEF0123456789ABCDEF'; my $plaintext = 'hello world'; my $ascii_cyphertext = &encrypt ($plaintext, $key); print "\n$ascii_cyphertext";

    Hope this helps.

    Martin
Re: Encryption using Tea algorithm (New Variant)
by mkirank (Chaplain) on Jan 17, 2006 at 10:14 UTC
    marto As I had mentioned , encrypt method uses CBC for encryption and I require the output the same as the Java Program.
      mkirank,

      What you did not mention is that the Java Program does not use CBC.
      In the first paragraph of the question you say:

      'but I could not find anything on how to use the same (encrypt method of Tea_JS uses CBC).'

      The same as what? At this point you have not even mentioned the Java program you are using and at no point in your question do you mention that the Java program does not use CBC. Posts that include as much relevant information as the poster can provide are generally easier for people to answer.

      Martin
Re: Encryption using Tea algorithm (New Variant)
by tirwhan (Abbot) on Jan 17, 2006 at 10:54 UTC

    The Java code you link to uses ECB mode to encrypt the data, which is extremely insecure (look at this Wikipedia article for a simple and graphic explanation of why). To be frank, taken together with the well-known weaknesses TEA has, you probably might as well not bother encrypting your data at all if you use this method.

    If you absolutely want to use TEA in EBC mode you can't use Crypt::Tea, since it sensibly uses CBC mode (as you've already found out). You'll have to implement it yourself, the algorithm basically consists of a few lines of C, so this shouldn't be too hard ;-). I'd recommend going the other way though and modifying your Java code to use CBC as well (not rocket science either).


    There are ten types of people: those that understand binary and those that don't.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://523709]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2014-07-13 10:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (249 votes), past polls