mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: replace []byte with []u8
This commit is contained in:
@ -5,8 +5,8 @@ import crypto.sha1
|
||||
import encoding.base64
|
||||
|
||||
// htonl64 converts payload length to header bits
|
||||
fn htonl64(payload_len u64) []byte {
|
||||
mut ret := []byte{len: 8}
|
||||
fn htonl64(payload_len u64) []u8 {
|
||||
mut ret := []u8{len: 8}
|
||||
ret[0] = u8(((payload_len & (u64(0xff) << 56)) >> 56) & 0xff)
|
||||
ret[1] = u8(((payload_len & (u64(0xff) << 48)) >> 48) & 0xff)
|
||||
ret[2] = u8(((payload_len & (u64(0xff) << 40)) >> 40) & 0xff)
|
||||
@ -19,9 +19,9 @@ fn htonl64(payload_len u64) []byte {
|
||||
}
|
||||
|
||||
// create_masking_key returs a new masking key to use when masking websocket messages
|
||||
fn create_masking_key() []byte {
|
||||
fn create_masking_key() []u8 {
|
||||
mask_bit := rand.u8()
|
||||
buf := []byte{len: 4, init: `0`}
|
||||
buf := []u8{len: 4, init: `0`}
|
||||
unsafe { C.memcpy(buf.data, &mask_bit, 4) }
|
||||
return buf
|
||||
}
|
||||
@ -45,7 +45,7 @@ fn create_key_challenge_response(seckey string) ?string {
|
||||
|
||||
// get_nonce creates a randomized array used in handshake process
|
||||
fn get_nonce(nonce_size int) string {
|
||||
mut nonce := []byte{len: nonce_size, cap: nonce_size}
|
||||
mut nonce := []u8{len: nonce_size, cap: nonce_size}
|
||||
alphanum := '0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz'
|
||||
for i in 0 .. nonce_size {
|
||||
nonce[i] = alphanum[rand.intn(alphanum.len) or { 0 }]
|
||||
|
Reference in New Issue
Block a user