Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xxtea-python results not matching xxxtea-pecl, xxtea-c, or xxtea-js #1

Closed
jondale opened this issue Feb 28, 2017 · 3 comments
Closed

Comments

@jondale
Copy link

jondale commented Feb 28, 2017

I am unable to get the python lib to match results from other languages xxtea libs.

I am using the following parameters:
key = 1234567890123456
str = TEST MESSAGE

I am encrypting and then base64 encode the answer.

The python lib gives me the result:
zH1tvARq5Vo+DR3PlcvPgA==

All other libs I have tried give me the result:
UooYNJx42NPS4lWOVBFaNw==

Below is the code I'm using for each one:

xxtea-python

import xxtea
import base64

key = "1234567890123456"
msg = "TEST MESSAGE"

encrypted_data = xxtea.encrypt(msg, key)
encoded = base64.b64encode(encrypted_data)

print encoded

xxtea-pecl

$key = "1234567890123456";
$str = "TEST MESSAGE";

$encrypted_data = xxtea_encrypt($str, $key);
$encoded = base64_encode($encrypted_data);

print $encoded;

xxtea-c on an arduino

//https://github.com/xxtea/xxtea-c
#include "xxtea.h"

//https://github.com/boseji/rBASE64
#include "rBase64.h"


void setup() {
  
  Serial.begin(115200);
  Serial.println();

  const char *key = "1234567890123456";
  const char *text = "TEST MESSAGE";
  size_t len;
  
  unsigned char *s = xxtea_encrypt(text, strlen(text), key, &len);
  
  String encoded = rbase64.encode(s, len);

  Serial.println(encoded);
}

void loop() {
    
}

xxtea-js

<!DOCTYPE html>
<html>
    <head>
        <title>XXTEA test</title>
        <meta charset="UTF-8">
        <script src="xxtea.min.js" type="text/javascript"></script>
    </head>
    <body>
        <script type="text/javascript">
            var str = "TEST MESSAGE"; 
            var key = "1234567890123456";
            var encrypt_data = XXTEA.encryptToBase64(str, key);
            console.log(encrypt_data);
        </script>
    </body>
</html>
@andot
Copy link
Member

andot commented Feb 28, 2017

Maybe you installed wrong module. I tested this code:

import xxtea
import base64

key = "1234567890123456"
msg = "TEST MESSAGE"

encrypted_data = xxtea.encrypt(msg, key)
encoded = base64.b64encode(encrypted_data)

print encoded

The result is:

UooYNJx42NPS4lWOVBFaNw==

Do you installed this module:

pip install xxtea-py

@jondale
Copy link
Author

jondale commented Feb 28, 2017

Thank you andot. That must have been it. I have installed the correct one now and it works.

Also as a tangent note, when I pip install xxtea-py on Fedora 25 the __pycache__ directory was not created and was giving me an error when trying to use xxtea-py. I created the directory /usr/lib/python2.7/site-packages/xxtea/__pycache__ on my machine and it works fine.

@fingpop
Copy link

fingpop commented Jun 18, 2019

import xxtea
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Traceback (most recent call last):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants