Skip to content

sayak-dutta/fingerprint-auth-macos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FingerprintAuth

A simple tool for fingerprint authentication on macOS, written in Swift and easily usable from various programming languages.

Building the Tool

  1. Clone the repository:
git clone https://github.com/sayak-dutta/fingerprint-auth-macos.git FingerprintAuth
cd FingerprintAuth
  1. Build the Swift package:
cd FingerprintAuth
swift build -c release

Using the Tool

Curl Command to Download Executable To include the executable in your project, you can use curl to download it from the repository:

curl -L -o FingerprintAuth https://github.com/yourusername/FingerprintAuth/releases/download/v1.0.0/FingerprintAuth](https://github.com/sayak-dutta/fingerprint-auth-macos/raw/main/.build/arm64-apple-macosx/release/FingerprintAuth
chmod +x FingerprintAuth

Examples

Golang

package main

import (
    "fmt"
    "os/exec"
)

func authenticateWithFingerprint() (bool, error) {
    cmd := exec.Command("./FingerprintAuth")
    output, err := cmd.CombinedOutput()
    if err != nil {
        return false, err
    }
    return string(output) == "Authentication successful\n", nil
}

func main() {
    success, err := authenticateWithFingerprint()
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    if success {
        fmt.Println("Fingerprint authentication succeeded")
    } else {
        fmt.Println("Fingerprint authentication failed")
    }
}

JavaScript (Node.js)

const { exec } = require('child_process');

exec('./FingerprintAuth', (error, stdout, stderr) => {
    if (error) {
        console.error(`Error: ${error.message}`);
        return;
    }
    if (stderr) {
        console.error(`Stderr: ${stderr}`);
        return;
    }
    console.log(stdout.trim() === 'Authentication successful' ? 'Fingerprint authentication succeeded' : 'Fingerprint authentication failed');
});

C

#include <stdio.h>
#include <stdlib.h>

int main() {
    char buffer[128];
    FILE *fp = popen("./FingerprintAuth", "r");
    if (fp == NULL) {
        perror("Error");
        return 1;
    }

    while (fgets(buffer, sizeof(buffer), fp) != NULL) {
        if (strcmp(buffer, "Authentication successful\n") == 0) {
            printf("Fingerprint authentication succeeded\n");
        } else {
            printf("Fingerprint authentication failed\n");
        }
    }

    pclose(fp);
    return 0;
}

Rust

use std::process::Command;

fn main() {
    let output = Command::new("./FingerprintAuth")
        .output()
        .expect("Failed to execute command");

    if output.status.success() {
        let stdout = String::from_utf8_lossy(&output.stdout);
        if stdout.trim() == "Authentication successful" {
            println!("Fingerprint authentication succeeded");
        } else {
            println!("Fingerprint authentication failed");
        }
    } else {
        eprintln!("Error: {:?}", output);
    }
}

Conclusion

This setup allows developers to easily integrate fingerprint authentication into their projects by downloading and running the Swift executable. The provided examples show how to call the executable from Golang, Node.js, C, and Rust. By following these steps and including detailed instructions in your README.md, you can make your tool accessible and easy to use for other developers.

About

A Fingerprint Authentication module for everyone

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages