1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vlib: run vfmt over vlib files, so that v doc -m vlib/ can run without warnings

This commit is contained in:
Delyan Angelov
2020-10-21 12:23:03 +03:00
parent 5b1ab3b0bb
commit dab66593fc
27 changed files with 343 additions and 334 deletions

View File

@ -1,16 +1,13 @@
// Copyright (c) 2019-2020 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
// Package rc4 implements RC4 encryption, as defined in Bruce Schneier's
// Applied Cryptography.
//
// RC4 is cryptographically broken and should not be used for secure
// applications.
// Based off: https://github.com/golang/go/blob/master/src/crypto/rc4
// Last commit: https://github.com/golang/go/commit/b35dacaac57b039205d9b07ea24098e2c3fcb12e
module rc4
import crypto.internal.subtle
@ -30,14 +27,14 @@ pub fn new_cipher(key []byte) ?Cipher {
return error('crypto.rc4: invalid key size ' + key.len.str())
}
mut c := Cipher{
s: []u32{len:(256)}
s: []u32{len: (256)}
}
for i in 0..256 {
for i in 0 .. 256 {
c.s[i] = u32(i)
}
mut j := byte(0)
for i in 0..256 {
j += byte(c.s[i]) + key[i%key.len]
for i in 0 .. 256 {
j += byte(c.s[i]) + key[i % key.len]
tmp := c.s[i]
c.s[i] = c.s[j]
c.s[j] = tmp
@ -59,7 +56,7 @@ pub fn (mut c Cipher) reset() {
// xor_key_stream sets dst to the result of XORing src with the key stream.
// Dst and src must overlap entirely or not at all.
pub fn (mut c Cipher) xor_key_stream(mut dst, src []byte) {
pub fn (mut c Cipher) xor_key_stream(mut dst []byte, mut src []byte) {
if src.len == 0 {
return
}
@ -75,7 +72,7 @@ pub fn (mut c Cipher) xor_key_stream(mut dst, src []byte) {
y := c.s[j]
c.s[i] = y
c.s[j] = x
dst[k] = v ^ byte(c.s[byte(x+y)])
dst[k] = v ^ byte(c.s[byte(x + y)])
}
c.i = i
c.j = j