A simple tool for fingerprint authentication on macOS, written in Swift and easily usable from various programming languages.
- Clone the repository:
git clone https://github.com/sayak-dutta/fingerprint-auth-macos.git FingerprintAuth
cd FingerprintAuth
- Build the Swift package:
cd FingerprintAuth
swift build -c release
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
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")
}
}
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');
});
#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;
}
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);
}
}
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.