<commit_before>#
# Simple pyrex access wrapper for libxxtea
#
cdef extern from "xxtea.h":
  int xxtea_decrypt(char* in_file, char* out_file, char* key)
  int xxtea_encrypt(char* in_file, char* out_file, char* key)
  cdef enum defines:
     XXTEA_SUCCESS = 0
     IN_FILE_ERROR = 1
     NO_READ_PERMS = 2
     NO_WRITE_PERMS = 3
     OUT_FILE_ERROR = 4
     READ_ERROR = 5
     FILE_SIZE_ERROR = 6

cdef extern from "keygen.h":
  void get_key(char* random_key, unsigned key_len)

def generate_key(char* random_key, int key_len):
   get_key(random_key, key_len)

def enc_xxtea(char* infile, char* outfile, char* key):
   ret = xxtea_encrypt(infile, outfile, key)
   return ret

def dec_xxtea(char* infile, char* outfile, char* key):
   ret = xxtea_decrypt(infile, outfile, key)
   return ret<commit_msg>added interface to work with 8 bytes<commit_after>#
# Simple pyrex access wrapper for libxxtea
#
cdef extern from "xxtea.h":
  int xxtea_decrypt(char* in_file, char* out_file, char* key)
  int xxtea_encrypt(char* in_file, char* out_file, char* key)
  long btea_8bytes( unsigned char* v, int n , unsigned char* k )
  
  cdef enum defines:
     XXTEA_SUCCESS = 0
     IN_FILE_ERROR = 1
     NO_READ_PERMS = 2
     NO_WRITE_PERMS = 3
     OUT_FILE_ERROR = 4
     READ_ERROR = 5
     FILE_SIZE_ERROR = 6
cdef extern from "Python.h":
   object PyString_FromStringAndSize(char*,int)
   
cdef extern from "keygen.h":
  void get_key(char* random_key, unsigned key_len)

def generate_key(char* random_key, int key_len):
   get_key(random_key, key_len)

def enc_xxtea(char* infile, char* outfile, char* key):
   ret = xxtea_encrypt(infile, outfile, key)
   return ret

def dec_xxtea(char* infile, char* outfile, char* key):
   ret = xxtea_decrypt(infile, outfile, key)
   return ret
# This might be the only function useful to kamaelia.
# 8 bytes of a passed parameter are processed. The rest are just ignored.

def xxbtea(char* data, int no , char* key):
    btea_8bytes(<unsigned char*>data, no,<unsigned char*>key)
    return PyString_FromStringAndSize(data,8)

{'fraction_non_alphanumeric': 0.09099756690997567, 'fraction_numerical': 0.009245742092457421, 'mean_word_length': 4.089108910891089, 'pattern_counts': {'":': 5, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4208473', 'n_tokens_mistral': 796, 'n_tokens_neox': 765, 'n_words': 224}