Skip to main content

A C-level keyring module bind from the Rust programming language (crates.io)

Project description

rskeyring (Rust Keyring)

A C-level, Rust keyring library bind to Python (https://github.com/DK26/pyrust-keyring).
The Rust library (crate) itself was created by hwchen (https://github.com/hwchen/keyring-rs).

Motivation

Since using pypi.org keyring library to store sensitive data with the PyInstaller library
isn't possible at the moment due to the error keyring.errors.NoKeyringError and since
it has been like this for a long time now, I've decided to try to bind the Rust programming language
keyring library (as I'm still learning it) to Python and been able to do so successfully.

Tested successfully on Windows 10 to work with PyInstaller.

Installation

pip install rskeyring

Usage

Store or Update Password

import rskeyring
from getpass import getpass

username = input("Username: ")
password = getpass()

try:
    rskeyring.set_password("service", username, password)
except OSError:
    print(f"Unable to create or update service for {username}."
        f"\nPlease make sure you have the proper permissions")

Retrieve Password

import rskeyring

username = input("Username: ")
try:
    password = rskeyring.get_password("service", username)
    print(password)
except OSError:
    print(f"Unable to get {username}'s password from 'service'")

Delete Password

import rskeyring

username = input("Username: ")

try:
    rskeyring.delete_password("service", username)
except OSError:
    print(f"Unable to remove {username} from 'service'")

Exceptions

Currently the external Rust kerying-rs library doesn't provide any concrete error details.
At this stage, we just throw a general OSError with an error message originated by the underlying Rust library itself.

  • e.g. OSError: Windows Vault Error

Unit Tests

python -m unittest tests.lib_unittest

Manual Use of Compiled Library

The setuptools_rust should be able to automatically compile & copy the rust libraries upon calling pip install rskeyring.

If you wish to compile and import the Rust libraries to your python setup manually, please refer to the following notes:

Compile

In order to compile the Rust code, you'll need to have the rustup toolchain.
To install the rustup toolchain, go to https://rustup.rs

From within this directory, execute the next command to compile:
cargo build --release

Windows

Copy the file pyrust-keyring\target\release\rskeyring.dll to your Python project. Make sure you rename its extension from .dll to .pyd.

MacOS

Copy the file pyrust-keyring/target/release/rskeyring.dylib to your Python project. Make sure you rename its extension from .dylib to .so.

Docs

help(rskeyring)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rskeyring-0.1.2.2.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rskeyring-0.1.2.2-cp38-cp38-win_amd64.whl (181.6 kB view details)

Uploaded CPython 3.8Windows x86-64

File details

Details for the file rskeyring-0.1.2.2.tar.gz.

File metadata

  • Download URL: rskeyring-0.1.2.2.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for rskeyring-0.1.2.2.tar.gz
Algorithm Hash digest
SHA256 a04a17e70155f30f4551c632e90a86e2b55256e411c785fcf39e26ddc6078c5c
MD5 1b5e31a9ce13da8f6ea5a51dc2fd0b78
BLAKE2b-256 eeae74798bdab8ec7f10231c91c93600452d20c2c5a5ecc9b49f67cf502ad391

See more details on using hashes here.

File details

Details for the file rskeyring-0.1.2.2-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: rskeyring-0.1.2.2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 181.6 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for rskeyring-0.1.2.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 94c88f6784a9c306dd1d636db81263d66a0f31780ef147a4241d7deab7ea74c9
MD5 20654780a132c89277274937c439de0b
BLAKE2b-256 509d60d875d219ceb199d947483149e00441521dc30c65c37505cb731bf74b43

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page