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

discontinued
outdated

This package enables Dart developers to use various C APIs by Apple (Core Foundation, Security, etc.).

example/example.dart

import 'dart:ffi';
import 'package:ffi/ffi.dart';

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 = allocate<Pointer<CFError>>();

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

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

    // Check for errors
    final error = errorPtrPtr.value.toDart();
    if (error != null) {
      throw error;
    }

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

Publisher

unverified uploader

This package enables Dart developers to use various C APIs by Apple (Core Foundation, Security, etc.).

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

ffi, meta

More

Packages that depend on cupertino_ffi