cupertino_ffi 0.1.0 copy "cupertino_ffi: ^0.1.0" to clipboard
cupertino_ffi: ^0.1.0 copied to clipboard

discontinued
outdated

Provides C bindings ('dart:ffi') for various APIs by Apple. These include Core Foundation (CFDictionary, etc.), Security (cryptography, biometrics, etc.), and Objective-C runtime.

example/example.dart

import 'dart:ffi';

import 'package:cupertino_ffi/core_foundation.dart';
import 'package:cupertino_ffi/security.dart';

void main() {
  arcPush();
  try {
    // Allocate an error variable on heap.
    final errorPtrPtr = Pointer<Pointer<CFError>>.allocate();
    errorPtrPtr.cast<IntPtr>().store(0);

    // Define RSA key attributes
    final attributes = CFDictionary.fromPointerMap({
      kSecAttrKeyType: kSecAttrKeyTypeRSA,
      kSecAttrKeySizeInBits: CFNumber.fromDartInt(2048),
    });

    // Generate a random key.
    final secKey = SecKeyCreateRandomKey(attributes, errorPtrPtr);

    // Check for errors
    final error = CFError.toDart(errorPtrPtr.load<Pointer<CFError>>());
    if (error != null) {
      throw error;
    }

    // Get public key
    final publicKey = SecKeyCopyPublicKey(secKey);
  } finally {
    arcPop();
  }
}
3
likes
0
pub points
30%
popularity

Publisher

unverified uploader

Provides C bindings ('dart:ffi') for various APIs by Apple. These include Core Foundation (CFDictionary, etc.), Security (cryptography, biometrics, etc.), and Objective-C runtime.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

ffi, meta

More

Packages that depend on cupertino_ffi