File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change 1
1
package websocket
2
2
3
- // Mask applies the WebSocket masking algorithm to p
3
+ // mask applies the WebSocket masking algorithm to p
4
4
// with the given key where the first 3 bits of pos
5
5
// are the starting position in the key.
6
6
// See https://tools.ietf.org/html/rfc6455#section-5.3
7
7
//
8
- // It is highly optimized to mask per word with the usage
9
- // of unsafe.
10
- //
11
- // For targets that do not support unsafe, please report an issue.
12
- // There is a mask by byte function below that will be used for such targets.
8
+ // The returned value is the position of the next byte
9
+ // to be used for masking in the key.
13
10
func mask (key [4 ]byte , pos int , p []byte ) int {
14
- panic ("TODO" )
11
+ for i := range p {
12
+ p [i ] ^= key [pos & 3 ]
13
+ pos ++
14
+ }
15
+ return pos & 3
15
16
}
You can’t perform that action at this time.
0 commit comments