You are reading a single comment by @d0773d and its replies. Click here to read the full conversation.
  • @Stevie i'm still getting the same issue, but now I am receiving
    MMM MMMMMMMMMMMMMMMUMMMM

    Full code:

    [#include](http://forum.espruino.com/sea­rch/?q=%23include) <stdio.h>
    [#include](http://forum.espruino.com/sea­rch/?q=%23include) <string.h>
    [#include](http://forum.espruino.com/sea­rch/?q=%23include) <stdint.h>
    
    // Enable both ECB and CBC mode. Note this can be done before including aes.h or at compile-time.
    // E.g. with GCC by using the -D flag: gcc -c aes.c -DCBC=0 -DECB=1
    [#define](http://forum.espruino.com/sear­ch/?q=%23define) CBC 1
    [#define](http://forum.espruino.com/sear­ch/?q=%23define) ECB 0 //ECB is not a very secure cipher to use.
    
    [#include](http://forum.espruino.com/sea­rch/?q=%23include) "aes.h"
    [#include](http://forum.espruino.com/sea­rch/?q=%23include) "jswrap_crypto.h"
    [#include](http://forum.espruino.com/sea­rch/?q=%23include) "jsinteractive.h"
    
    static void test_encrypt_cbc(void);
    
    
    
    static void test_encrypt_cbc(void)
    {
      uint8_t key[]    = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c };
      uint8_t iv[]     = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
    
      uint8_t in[128]  = { 0x7b, 0x22, 0x61, 0x72, 0x72, 0x61, 0x79, 0x22, 0x3a, 0x5b, 0x31, 0x2c, 0x32, 0x2c, 0x33, 0x5d,
                           0x2c, 0x22, 0x62, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x22, 0x3a, 0x74, 0x72, 0x75, 0x65, 0x2c,
                           0x22, 0x6e, 0x75, 0x6c, 0x6c, 0x22, 0x3a, 0x6e, 0x75, 0x6c, 0x6c, 0x2c, 0x22, 0x6e, 0x75, 0x6d,
                           0x62, 0x65, 0x72, 0x22, 0x3a, 0x31, 0x32, 0x33, 0x2c, 0x22, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74,
                           0x22, 0x3a, 0x7b, 0x22, 0x61, 0x22, 0x3a, 0x22, 0x62, 0x22, 0x2c, 0x22, 0x63, 0x22, 0x3a, 0x22,
                           0x64, 0x22, 0x2c, 0x22, 0x65, 0x22, 0x3a, 0x22, 0x66, 0x22, 0x7d, 0x2c, 0x22, 0x73, 0x74, 0x72,
                           0x69, 0x6e, 0x67, 0x22, 0x3a, 0x22, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c,
                           0x64, 0x22, 0x7d };
      uint8_t buffer[128];
    
      AES128_CBC_encrypt_buffer(buffer, in, 128, key, iv);
    
      int i;
    
      for(i = 0; i < 128; ++i)
        jsiConsolePrintf(in[i]);
      jsiConsolePrintf("\n");
    
      jsiConsolePrint("CBC encrypt: ");
    }
    

    1 Attachment

    • 2015-05-27 23_59_29-Espruino Web IDE.png
About

Avatar for d0773d @d0773d started