Skip to content

Commit 0ed4fcb

Browse files
authored
Merge pull request #8 from Naxdy/work/misc-chores
treefmt, crate info
2 parents 38d3dd1 + 56debae commit 0ed4fcb

File tree

10 files changed

+164
-55
lines changed

10 files changed

+164
-55
lines changed

.github/workflows/publish-crate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ jobs:
2525

2626
- uses: katyo/publish-crates@v2
2727
with:
28-
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
28+
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
[package]
2+
description = "Static encryption for string literals and binary data"
23
name = "staticrypt"
4+
edition.workspace = true
5+
license.workspace = true
6+
repository.workspace = true
37
version.workspace = true
4-
edition = "2024"
5-
license = "MIT"
6-
description = "Static encryption for string literals and binary data"
8+
authors.workspace = true
79

810
[workspace]
911
members = [".", "macros", "testbin"]
1012

1113
[workspace.package]
12-
version = "1.1.0"
14+
edition = "2024"
15+
license = "MIT"
16+
repository = "https://github.com/Naxdy/staticrypt"
17+
version = "1.1.1"
18+
authors = ["Naxdy <naxdy@naxdy.org>"]
1319

1420
[workspace.dependencies]
1521
aes-gcm = "0.10.3"
1622

1723
[dependencies]
1824
aes-gcm.workspace = true
19-
staticrypt_macros = { version = "1.1.0", path = "macros" }
25+
staticrypt_macros = { version = "1.1.1", path = "macros" }

README.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
# Staticrypt
1+
# Staticrypt
22

3-
The name is an abbreviation of "Static Encryption" - a Rust proc macro libary to encrypt text
4-
literals or binary data using AES-256.
3+
The name is an abbreviation of "Static Encryption" - a Rust proc macro library to encrypt text
4+
literals or binary data using AES-256.
55

6-
The crate is intended to be a successor to [`litcrypt`](https://docs.rs/litcrypt/latest/litcrypt/),
7-
and expand on the overall idea of the library.
6+
The crate is intended to be a successor to [`litcrypt`](https://docs.rs/litcrypt/latest/litcrypt/),
7+
and expand on the overall idea of the library.
88

9-
Like litcrypt, staticrypt works by encrypting the given data at compile time. In its place, it
10-
leaves the encrypted contents and a 96 bit nonce (unique for every encrypted item), protecting
11-
your data from static analysis tools.
9+
Like litcrypt, staticrypt works by encrypting the given data at compile time. In its place, it
10+
leaves the encrypted contents and a 96 bit nonce (unique for every encrypted item), protecting
11+
your data from static analysis tools.
1212

13-
In contrast to to litcrypt's `lc`, staticrypt's `sc` supports all valid Rust string literals,
14-
including those with escape sequences, unicode characters, etc.
13+
In contrast to to litcrypt's `lc`, staticrypt's `sc` supports all valid Rust string literals,
14+
including those with escape sequences, unicode characters, etc.
1515

16-
To initialize staticrypt in a crate, the `use_staticrypt` macro needs to be called first. See
17-
its doc page for more info on initial setup.
16+
To initialize staticrypt in a crate, the `use_staticrypt` macro needs to be called first. See
17+
its doc page for more info on initial setup.
1818

19-
## Example
19+
## Example
2020

21-
```rust
22-
use staticrypt::*;
21+
```rust
22+
use staticrypt::*;
2323

24-
// Needs to be present at the root of the crate.
25-
use_staticrypt!();
24+
// Needs to be present at the root of the crate.
25+
use_staticrypt!();
2626

27-
fn main() {
28-
// Protect sensitive information from static analysis / tampering
29-
println!("The meaning of life is {}", sc!("42"));
30-
}
31-
```
27+
fn main() {
28+
// Protect sensitive information from static analysis / tampering
29+
println!("The meaning of life is {}", sc!("42"));
30+
}
31+
```
3232

33-
Everything inside the `sc` macro will be encrypted at compile time. You can verify that none
34-
of the strings are present in cleartext using something like `strings`:
33+
Everything inside the `sc` macro will be encrypted at compile time. You can verify that none
34+
of the strings are present in cleartext using something like `strings`:
3535

36-
```shell
37-
strings target/debug/my_app | grep 42
38-
```
36+
```shell
37+
strings target/debug/my_app | grep 42
38+
```
3939

40-
If the output is blank / does not contain the string you are looking for, then your app is safe
41-
from static analysis tools.
40+
If the output is blank / does not contain the string you are looking for, then your app is safe
41+
from static analysis tools.
4242

43-
## DISCLAIMER
43+
## DISCLAIMER
4444

45-
Although using tools like staticrypt makes it very difficult for attackers to view or alter
46-
your data, it does _not_ make it impossible. You should develop your programs with the
47-
assumption that a sufficiently determined attacker will be able to reverse engineer your
48-
encryption and gain access to any data present in your binary, so it is **highly discouraged** to
49-
use this crate to embed sensitive information like API keys, passwords, private keys etc. in your
50-
application.
45+
Although using tools like staticrypt makes it very difficult for attackers to view or alter
46+
your data, it does _not_ make it impossible. You should develop your programs with the
47+
assumption that a sufficiently determined attacker will be able to reverse engineer your
48+
encryption and gain access to any data present in your binary, so it is **highly discouraged** to
49+
use this crate to embed sensitive information like API keys, passwords, private keys etc. in your
50+
application.

flake.lock

Lines changed: 36 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
crane.url = "github:ipetkov/crane";
88

99
fenix.url = "github:nix-community/fenix";
10+
11+
treefmt-nix.url = "github:numtide/treefmt-nix";
1012
};
1113

1214
outputs =
@@ -15,12 +17,16 @@
1517
nixpkgs,
1618
crane,
1719
fenix,
20+
treefmt-nix,
1821
}:
1922
let
2023
supportedSystems = [
2124
"x86_64-linux"
2225
"aarch64-linux"
26+
"x86_64-darwin"
27+
"aarch64-darwin"
2328
];
29+
2430
forEachSupportedSystem =
2531
f:
2632
nixpkgs.lib.genAttrs supportedSystems (
@@ -54,25 +60,43 @@
5460
};
5561

5662
cargoArtifacts = craneLib.buildDepsOnly craneArgs;
63+
64+
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
65+
66+
treefmtEval = treefmt-nix.lib.evalModule pkgs (
67+
import ./treefmt.nix { inherit rustToolchain cargoToml; }
68+
);
69+
70+
treefmt = treefmtEval.config.build.wrapper;
5771
in
5872
f {
5973
inherit
60-
pkgs
61-
rustToolchain
62-
craneLib
6374
cargoArtifacts
6475
craneArgs
76+
craneLib
77+
pkgs
78+
rustToolchain
79+
treefmt
80+
treefmtEval
6581
;
6682
}
6783
);
6884
in
6985
{
86+
formatter = forEachSupportedSystem ({ treefmt, ... }: treefmt);
87+
7088
devShells = forEachSupportedSystem (
71-
{ pkgs, rustToolchain, ... }:
89+
{
90+
pkgs,
91+
rustToolchain,
92+
treefmt,
93+
...
94+
}:
7295
{
7396
default = pkgs.mkShell {
7497
nativeBuildInputs = [
7598
rustToolchain
99+
treefmt
76100
];
77101

78102
STATICRYPT_SEED = "01234567890123456789012345678901";
@@ -86,9 +110,12 @@
86110
craneLib,
87111
cargoArtifacts,
88112
craneArgs,
113+
treefmtEval,
89114
...
90115
}:
91116
{
117+
treefmt = treefmtEval.config.build.check self;
118+
92119
cargoDoc = craneLib.cargoDoc (craneArgs // { inherit cargoArtifacts; });
93120

94121
cargoTest = craneLib.cargoTest (

macros/Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
[package]
22
name = "staticrypt_macros"
3-
version.workspace = true
4-
edition = "2024"
5-
license = "MIT"
63
description = "Macros for the `staticrypt` crate"
4+
edition.workspace = true
5+
license.workspace = true
6+
repository.workspace = true
7+
version.workspace = true
8+
authors.workspace = true
79

810
[lib]
911
proc-macro = true

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! # Staticrypt
22
//!
3-
//! The name is an abbreviation of "Static Encryption" - a Rust proc macro libary to encrypt text
3+
//! The name is an abbreviation of "Static Encryption" - a Rust proc macro library to encrypt text
44
//! literals or binary data using [`Aes256Gcm`].
55
//!
66
//! The crate is intended to be a successor to the [`litcrypt`](https://docs.rs/litcrypt/latest/litcrypt/),

testbin/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
[package]
22
name = "staticrypt_testbin"
33
version.workspace = true
4-
edition = "2024"
4+
edition.workspace = true
5+
repository.workspace = true
6+
license.workspace = true
7+
authors.workspace = true
58
publish = false
69

710
[dependencies]

treefmt.nix

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{ rustToolchain, cargoToml }:
2+
{ pkgs, ... }:
3+
{
4+
# rust
5+
programs.rustfmt = {
6+
enable = true;
7+
package = rustToolchain;
8+
edition = cargoToml.workspace.package.edition or cargoToml.package.edition;
9+
};
10+
11+
# nix
12+
programs.nixfmt.enable = true;
13+
14+
# toml
15+
programs.taplo.enable = true;
16+
17+
# markdown, yaml, etc.
18+
programs.prettier = {
19+
enable = true;
20+
settings = {
21+
trailingComma = "all";
22+
semi = true;
23+
printWidth = 120;
24+
singleQuote = true;
25+
};
26+
};
27+
28+
programs.typos = {
29+
enable = true;
30+
includes = [
31+
"*.rs"
32+
"*.md"
33+
"*.yml"
34+
];
35+
};
36+
}

0 commit comments

Comments
 (0)