Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Encryption on Netduino Plus


  • Please log in to reply
5 replies to this topic

#1 johnstaveley

johnstaveley

    Member

  • Members
  • PipPip
  • 15 posts
  • LocationLeeds, UK

Posted 21 November 2012 - 03:33 PM

Hi, sorry for this question but I'm getting nowhere with it. I am running .netmf 4.2 on a netduino plus and want to implement the following:

using System;
using System.Text;
using Microsoft.SPOT;
using Microsoft.SPOT.Cryptography;

namespace myNamespace
{
    public class Encryption
    {
        public static string Encrypt(string message)
        {

            string key = "0x081632";
            byte[] data = Encoding.UTF8.GetBytes(message);
            byte[] xteaKey = Encoding.UTF8.GetBytes(key);
            Key_TinyEncryptionAlgorithm xtea = new Key_TinyEncryptionAlgorithm(xteaKey);
            byte[] encryptedBytes = xtea.Encrypt(data, 0, data.Length, xteaKey);
            string encryptedString = Convert.ToBase64String(encryptedBytes);
            return encryptedString;

        }
    }
}

I have a reference to Microsoft.SPOT.Native which holds the Microsoft.SPOT.Cryptography namespace according to

http://msdn.microsof...y/cc506813.aspx

but I keep getting the following error:

The type or namespace name 'Cryptography' does not exist in the namespace 'Microsoft.SPOT' (are you missing an assembly reference?)

I've also heard mention that I need to 'install' Cryptography library on the netduino plus. Is this correct, if so how to I do it?

thanks,

John

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 21 November 2012 - 03:57 PM

Hi John, I believe that the crypto classes are in the legacy (non-open-source) add-ons for NETMF. If you want to compile them into the Netduino firmware, you can certainly do so. They will take up some flash. There's extra flash available on Netduino Plus 2 which won't consume code space. Chris

#3 johnstaveley

johnstaveley

    Member

  • Members
  • PipPip
  • 15 posts
  • LocationLeeds, UK

Posted 22 November 2012 - 08:27 AM

ok thanks, how would you suggest I go about this then without having to recompile the framework, is there a simple option I am missing here? A pointer to an existing example would be helpful. John

#4 johnstaveley

johnstaveley

    Member

  • Members
  • PipPip
  • 15 posts
  • LocationLeeds, UK

Posted 29 November 2012 - 01:56 PM

It appears this is covered here: http://download.code...wnloadId=257829 taken from: http://netmf.codeple...m/documentation

#5 Geancarlo2

Geancarlo2

    Advanced Member

  • Members
  • PipPipPip
  • 70 posts

Posted 29 November 2012 - 02:20 PM

If performance is not an issue, you can adapt from http://code.google.c...Packets/Xtea.cs or the public domain implementation found on wikipedia. I'm sure you can find other c# implementations that don't use unsafe code too.

#6 johnstaveley

johnstaveley

    Member

  • Members
  • PipPip
  • 15 posts
  • LocationLeeds, UK

Posted 29 November 2012 - 05:00 PM

If performance is not an issue, you can adapt from http://code.google.c...Packets/Xtea.cs or the public domain implementation found on wikipedia. I'm sure you can find other c# implementations that don't use unsafe code too.


Hi, the dll already exists on the netduino plus so I think I will use that instead. The docs at the link I gave give examples of how to generate a CryptoKey and then use it but don't explain how to generate a fixed crypto key which I can then use to decrypt the package on a web server. Suggestions welcome.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.