Maui - Bit locker in MAC

Dani_S 4,501 Reputation points
2023-09-07T12:02:51.3566667+00:00

Hi,

I used this code to check if USB is bit locker , how is done in MAC ?

Thanks,


#if WINDOWS
using Microsoft.WindowsAPICodePack.Shell.PropertySystem;
using Microsoft.WindowsAPICodePack.Shell;

namespace GssdDesktopClient.Maui.Helpers
{
    public class BitLockerHelper
    {
        public static (bool,int) IsBitLockerVolume(string drive)
        {
            IShellProperty prop = ShellObject.FromParsingName(drive).Properties.GetProperty("System.Volume.BitLockerProtection");
            int? bitLockerProtectionStatus = (prop as ShellProperty<int?>).Value;

            if (bitLockerProtectionStatus.HasValue && (bitLockerProtectionStatus == 1 ||
                bitLockerProtectionStatus == 3 || bitLockerProtectionStatus == 5 || bitLockerProtectionStatus == 6))
                return (true, bitLockerProtectionStatus.Value);
            return (false,bitLockerProtectionStatus.Value);
        }
    }
}
#endif
Developer technologies | .NET | .NET MAUI
{count} votes

Accepted answer
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 36,436 Reputation points Microsoft External Staff
    2023-09-08T03:37:19.2033333+00:00

    Hello,

    Bitlocker is a Windows disk encryption feature and it's not supported for MacOS. Please see BitLocker overview.

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 78,006 Reputation points Volunteer Moderator
    2023-09-20T15:38:58.22+00:00

    macOS supports encryption. Sample command line app where you pass the volume name to check.

    import Foundation
    
    func main() {
        for s in CommandLine.arguments[1...] {
            let u = URL(fileURLWithPath: s)
            let rv = try! u.resourceValues(forKeys: [.volumeIsEncryptedKey])
            print(u.path)
            print(rv.volumeIsEncrypted!)
        }
    }
    
    main()
    exit(EXIT_SUCCESS)
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.