class Shatter::Crypto::CipherStreamIO

Defined in:

shatter/crypto.cr

Constructors

Instance Method Summary

Instance methods inherited from class IO

read_angle : Float64 read_angle, read_bool : Bool read_bool, read_f32 : Float32 read_f32, read_f64 : Float64 read_f64, read_i16 : Int16 read_i16, read_i32 : Int32 read_i32, read_i64 : Int64 read_i64, read_i8 : Int8 read_i8, read_n_bytes(size : Int) : Bytes read_n_bytes, read_u16 : UInt16 read_u16, read_u32 : UInt32 read_u32, read_u64 : UInt64 read_u64, read_u8 : UInt8 read_u8, read_uuid : UUID read_uuid, read_var_int : UInt32 read_var_int, read_var_long : UInt64 read_var_long, read_var_string : String read_var_string, write_bool(i : Bool) : Nil write_bool, write_f32(i : Float32) : Nil write_f32, write_f64(i : Float64) : Nil write_f64, write_i16(i : Int16) : Nil write_i16, write_i32(i : Int32) : Nil write_i32, write_i64(i : Int64) : Nil write_i64, write_i8(i : Int8) : Nil write_i8, write_u16(i : UInt16) : Nil write_u16, write_u32(i : UInt32) : Nil write_u32, write_u64(i : UInt64) : Nil write_u64, write_u8(i : UInt8) : Nil write_u8, write_var_int(value : Int32) : Nil
write_var_int(value : UInt32) : Nil
write_var_int
, write_var_string(s : String) : Nil write_var_string

Constructor Detail

def self.new(io : IO, cipher_method : String, iv : Bytes, key : Bytes) #

[View source]

Instance Method Detail

def flush #
Description copied from class IO

Flushes buffered data, if any.

IO defines this is a no-op method, but including types may override.


[View source]
def read(slice : Bytes) #
Description copied from class IO

Reads at most slice.size bytes from this IO into slice. Returns the number of bytes read, which is 0 if and only if there is no more data to read (so checking for 0 is the way to detect end of file).

io = IO::Memory.new "hello"
slice = Bytes.new(4)
io.read(slice) # => 4
slice          # => Bytes[104, 101, 108, 108]
io.read(slice) # => 1
slice          # => Bytes[111, 101, 108, 108]
io.read(slice) # => 0

[View source]
def read_cipher : OpenSSL::Cipher #

[View source]
def write(slice : Bytes) : Nil #
Description copied from class IO

Writes the contents of slice into this IO.

io = IO::Memory.new
slice = Bytes.new(4) { |i| ('a'.ord + i).to_u8 }
io.write(slice)
io.to_s # => "abcd"

[View source]
def write_cipher : OpenSSL::Cipher #

[View source]