Skip to content

Commit

Permalink
use base64 v0.21
Browse files Browse the repository at this point in the history
  • Loading branch information
zephyrchien committed Dec 9, 2023
1 parent 29bb726 commit 6a39e46
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lightws"
version = "0.6.9"
version = "0.6.10"
authors = ["zephyr <[email protected]>"]
description = "Lightweight websocket implement for stream transmission."
repository = "https://github.com/zephyrchien/lightws"
Expand All @@ -19,12 +19,12 @@ unsafe_auto_mask_write = []
cfg-if = "1"
rand = "0.8"
sha1 = "0.10"
base64 = "0.20.0-alpha.1"
base64 = "0.21"
httparse = "1"
tokio = { version = "1", optional = true }


[dev-dependencies]
log = "0.4"
env_logger = "0.9"
env_logger = "0.10"
tokio = { version = "1", features = ["full"] }
7 changes: 4 additions & 3 deletions src/handshake/key.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
//! Key exchange.
use super::GUID;
use base64::engine::DEFAULT_ENGINE;
use base64::Engine;
use base64::engine::general_purpose::STANDARD;
use sha1::{Digest, Sha1};

/// Generate a new `sec-websocket-key`.
#[inline]
pub fn new_sec_key() -> [u8; 24] {
let input: [u8; 16] = rand::random();
let mut output = [0_u8; 24];
base64::encode_engine_slice(input, &mut output, &DEFAULT_ENGINE);
Engine::encode_slice(&STANDARD, input, &mut output).unwrap();
output
}

Expand All @@ -21,7 +22,7 @@ pub fn derive_accept_key(sec_key: &[u8]) -> [u8; 28] {
sha1.update(GUID);
let input = sha1.finalize();
let mut output = [0_u8; 28];
base64::encode_engine_slice(input, &mut output, &DEFAULT_ENGINE);
Engine::encode_slice(&STANDARD, input, &mut output).unwrap();
output
}

Expand Down

0 comments on commit 6a39e46

Please sign in to comment.