views:

114

answers:

2

In my windows mobile application (v.6.x) I'm downloading media files onto the device. Is there a beaten path for encrypting this content? So that the media file can just be decrypted by the application, e.g. shuffle every 100th byte or something like that

+1  A: 

You can have a look at the Cryptography namespace in the Compact Framework which has several classes for encrypting and decrypting data, for example the RijndaelManaged class which provides AES encryption.

In the example on the RijndaelManaged page on MSDN you can see an example on how to encrypt and decrypt the content of a file. You should be able to use the same technique for your media files.

tomlog
+1  A: 

Might something like this work for you?

private Byte[] CryptoKey
{
    get { return new Byte[] { 0x0E, 0x41, 0x6A, 0x29, 0x94, 0x12, 0xEB, 0x63 }; }
}

public Byte[] Encrypt(Byte[] bytes)
{
    using (var crypto = new DESCryptoServiceProvider())
    {
        var key = CryptoKey;

        using (var encryptor = crypto.CreateEncryptor(key, key))
        {
            return encryptor.TransformFinalBlock(bytes, 0, bytes.Length);
        }
    }
}

public Byte[] Decrypt(Byte[] bytes)
{
    using (var crypto = new DESCryptoServiceProvider())
    {
        var key = CryptoKey;

        using (var decryptor = crypto.CreateDecryptor(key, key))
        {
            return decryptor.TransformFinalBlock(bytes, 0, bytes.Length);
        }
    }
}
Johann Gerell