diff options
| author | mat <git@matdoes.dev> | 2023-12-03 02:41:09 -0600 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-12-03 02:41:09 -0600 |
| commit | 1f46ef8c115db0c53e21dfb6a3e633825c6747c3 (patch) | |
| tree | 74e5fa5e76ac95bb68e6d07b999187e5a4e617c0 /azalea-auth/src | |
| parent | 0713223e1204438f839566ce8cf954f0c9ff7f91 (diff) | |
| download | azalea-drasl-1f46ef8c115db0c53e21dfb6a3e633825c6747c3.tar.xz | |
make it so plugins can send and receive packets during the login state
Diffstat (limited to 'azalea-auth/src')
| -rwxr-xr-x | azalea-auth/src/lib.rs | 1 | ||||
| -rw-r--r-- | azalea-auth/src/offline.rs | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/azalea-auth/src/lib.rs b/azalea-auth/src/lib.rs index bd151eb3..1643bf04 100755 --- a/azalea-auth/src/lib.rs +++ b/azalea-auth/src/lib.rs @@ -4,6 +4,7 @@ mod auth; pub mod cache; pub mod certs; pub mod game_profile; +pub mod offline; pub mod sessionserver; pub use auth::*; diff --git a/azalea-auth/src/offline.rs b/azalea-auth/src/offline.rs new file mode 100644 index 00000000..737555e8 --- /dev/null +++ b/azalea-auth/src/offline.rs @@ -0,0 +1,17 @@ +use md5::{Digest, Md5}; +use uuid::Uuid; + +pub fn generate_uuid(username: &str) -> Uuid { + uuid::Builder::from_md5_bytes(hash(format!("OfflinePlayer:{username}").as_bytes())).into_uuid() +} + +fn hash(data: &[u8]) -> [u8; 16] { + let mut hasher = Md5::new(); + + hasher.update(data); + + let mut bytes = [0; 16]; + bytes.copy_from_slice(&hasher.finalize()[..16]); + + bytes +} |
