【问题标题】:Adobe Air encryption of mp3 file with as3crypto only encrypts the first few bytesAdobe Air 用 as3crypto 加密 mp3 文件只加密前几个字节
【发布时间】:2010-08-08 13:47:53
【问题描述】:

我正在使用 as3crypto 库来加密 Adob​​e Air 应用程序中的 mp3 文件。下面的代码运行没有错误,但我意识到只有 mp3 文件的前几个字节被加密,而不是整个文件。

我不知道有什么问题。有人可以这么好心看看我下面的代码吗?

import com.hurlant.crypto.symmetric.AESKey;
import com.hurlant.crypto.symmetric.DESKey;
import com.hurlant.util.Hex;

import mx.controls.Alert;

private static var stream:FileStream;
private static var stream2:FileStream;
private static var file:File;

private var fileToEncrypt:ByteArray;

private function encrypt():void
{
    file = File.documentsDirectory.resolvePath(”airenc/file1.mp3″);

    fileToEncrypt = new ByteArray;

    stream = new FileStream();
    stream.open( file, FileMode.READ );
    stream.readBytes(fileToEncrypt);
    stream.close();

    file = File.documentsDirectory.resolvePath(”airenc/file1-enc.mp3″);

    var key:ByteArray = Hex.toArray(”myEncKey”);
    var aes:AESKey = new AESKey(key);

    aes.encrypt(fileToEncrypt);

    stream2 = new FileStream();
    stream2.open( file, FileMode.WRITE );
    stream2.writeBytes(fileToEncrypt);
    stream2.close();

}

【问题讨论】:

    标签: apache-flex encryption air adobe as3crypto


    【解决方案1】:

    与此同时,我找到了解决方案。如果我更换:

    var aes:AESKey = new AESKey(key);

    var aes:ICipher = Crypto.getCipher(”simple-aes-ecb”, key,Crypto.getPad(”pkcs5″));

    它会加密整个文件。

    【讨论】:

      猜你喜欢
      • 2015-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-26
      • 1970-01-01
      • 2012-09-22
      • 2012-11-22
      • 1970-01-01
      相关资源
      最近更新 更多