Esempio n. 1
0
        public static IDstFSInterop Load(string dstpath, string?password = null)
        {
            DiskDstFSInterop diskDstFSInterop = new DiskDstFSInterop(dstpath);

            if (password != null)
            {
                byte[]    keyfile   = diskDstFSInterop.LoadIndexFileAsync(null, IndexFileType.EncryptorKeyFile).Result;
                AesHelper encryptor = AesHelper.CreateFromKeyFile(keyfile, password);
                diskDstFSInterop.Encryptor = encryptor;
            }
            return(diskDstFSInterop);
        }
Esempio n. 2
0
        public static IDstFSInterop InitializeNew(string dstpath, string?password = null)
        {
            DiskDstFSInterop diskDstFSInterop = new DiskDstFSInterop(dstpath);

            if (password != null)
            {
                AesHelper encryptor = AesHelper.CreateFromPassword(password);
                byte[]    keyfile   = encryptor.CreateKeyFile();
                diskDstFSInterop.StoreIndexFileAsync(null, IndexFileType.EncryptorKeyFile, keyfile).Wait();
                diskDstFSInterop.Encryptor = encryptor;
            }
            return(diskDstFSInterop);
        }