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:
@@ -1,7 +1,7 @@
|
||||
module blowfish
|
||||
|
||||
// expand_key performs a key expansion on the given Blowfish cipher.
|
||||
pub fn expand_key(key []byte, mut bf Blowfish) {
|
||||
pub fn expand_key(key []u8, mut bf Blowfish) {
|
||||
mut j := 0
|
||||
for i := 0; i < 18; i++ {
|
||||
mut d := u32(0)
|
||||
@@ -41,7 +41,7 @@ pub fn expand_key(key []byte, mut bf Blowfish) {
|
||||
}
|
||||
|
||||
// expand_key_with_salt using salt to expand the key.
|
||||
pub fn expand_key_with_salt(key []byte, salt []byte, mut bf Blowfish) {
|
||||
pub fn expand_key_with_salt(key []u8, salt []u8, mut bf Blowfish) {
|
||||
mut j := 0
|
||||
for i := 0; i < 18; i++ {
|
||||
bf.p[i] ^= get_next_word(key, &j)
|
||||
@@ -128,7 +128,7 @@ fn setup_tables(l u32, r u32, mut bf Blowfish) []u32 {
|
||||
|
||||
// get_next_word returns the next big-endian u32 value from the byte
|
||||
// slice at the given position in a circular manner, updating the position.
|
||||
fn get_next_word(b []byte, pos &int) u32 {
|
||||
fn get_next_word(b []u8, pos &int) u32 {
|
||||
mut w := u32(0)
|
||||
mut j := 0
|
||||
unsafe {
|
||||
|
||||
@@ -8,7 +8,7 @@ pub mut:
|
||||
|
||||
// new_cipher creates and returns a new Blowfish cipher.
|
||||
// The key argument should be the Blowfish key, from 1 to 56 bytes.
|
||||
pub fn new_cipher(key []byte) ?Blowfish {
|
||||
pub fn new_cipher(key []u8) ?Blowfish {
|
||||
mut bf := Blowfish{}
|
||||
unsafe { vmemcpy(&bf.p[0], &p[0], int(sizeof(bf.p))) }
|
||||
unsafe { vmemcpy(&bf.s[0], &s[0], int(sizeof(bf.s))) }
|
||||
@@ -21,7 +21,7 @@ pub fn new_cipher(key []byte) ?Blowfish {
|
||||
}
|
||||
|
||||
// new_salted_cipher returns a new Blowfish cipher that folds a salt into its key schedule.
|
||||
pub fn new_salted_cipher(key []byte, salt []byte) ?Blowfish {
|
||||
pub fn new_salted_cipher(key []u8, salt []u8) ?Blowfish {
|
||||
if salt.len == 0 {
|
||||
return new_cipher(key)
|
||||
}
|
||||
@@ -36,7 +36,7 @@ pub fn new_salted_cipher(key []byte, salt []byte) ?Blowfish {
|
||||
}
|
||||
|
||||
// encrypt encrypts the 8-byte buffer src using the key k and stores the result in dst.
|
||||
pub fn (mut bf Blowfish) encrypt(mut dst []byte, src []byte) {
|
||||
pub fn (mut bf Blowfish) encrypt(mut dst []u8, src []u8) {
|
||||
l := u32(src[0]) << 24 | u32(src[1]) << 16 | u32(src[2]) << 8 | u32(src[3])
|
||||
r := u32(src[4]) << 24 | u32(src[5]) << 16 | u32(src[6]) << 8 | u32(src[7])
|
||||
arr := setup_tables(l, r, mut bf)
|
||||
|
||||
Reference in New Issue
Block a user