开发者

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 encr开发者_运维知识库ypting this content? So that the media file can just be decrypted by the application, e.g. shuffle every 100th byte or something like that


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜