This repository has been archived by the owner on Oct 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
571 additions
and
84 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { invoke } from "@tauri-apps/api" | ||
|
||
/** | ||
* Generates random key | ||
*/ | ||
export const generateRandomKey = async (): Promise<Buffer> => { | ||
return Buffer.from(window.crypto.getRandomValues(new Uint8Array(32))) | ||
} | ||
|
||
/** | ||
* Sets an entry on the system keychain | ||
*/ | ||
export const setEntry = async (name: string, data: string) => { | ||
await invoke("set_entry", { name, data }) | ||
} | ||
|
||
/** | ||
* Gets an entry on the system keychain | ||
*/ | ||
export const getEntry = async (name: string): Promise<string> => { | ||
return await invoke("get_entry", { name }) | ||
} | ||
|
||
/** | ||
* Encrypts a string with the encryption key | ||
*/ | ||
export const encryptData = async (key: string, data: string): Promise<string> => { | ||
return await invoke("encrypt_data", { key, data }) | ||
} | ||
|
||
/** | ||
* Decrypts a string with the encryption key | ||
*/ | ||
export const decryptData = async (key: string, data: string): Promise<string> => { | ||
return await invoke("decrypt_data", { key, data }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.