leviathan
leviathan

Reputation: 11161

Windows Mobile content encryption

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

Upvotes: 0

Views: 1063

Answers (2)

Johann Gerell
Johann Gerell

Reputation: 25581

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);
        }
    }
}

Upvotes: 1

Tom van Enckevort
Tom van Enckevort

Reputation: 4198

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.

Upvotes: 1

Related Questions