class Sodium::Cipher::Salsa20
  
  - Sodium::Cipher::Salsa20
 - Sodium::Cipher::Chalsa
 - Reference
 - Object
 
Overview
These classes can be used to generate pseudo-random data from a key,
or as building blocks for implementing custom constructions, but they
are not alternatives to SecretBox.
See https://libsodium.gitbook.io/doc/advanced/stream_ciphers for further information.
This class mimicks the OpenSSL::Cipher interface with minor differences.
Also provides a ::Random interface.
- Lacks forward secrecy.
 - ~3x faster than 
::Random::Secure 
Use with caution.  When in doubt use ::Random::Secure
Possibly safe uses:
- Test data
 - Overwriting storage with random data
 - Single player video games (maybe)
 
See spec/sodium/cipher/chalsa_spec.cr for examples on how to use this class.
WARNING Not validated against test vectors. You should probably write some before using this class.
Defined in:
sodium/cipher/chalsa.crConstant Summary
- 
        KEY_SIZE = 
LibSodium.crypto_stream_salsa20_keybytes.to_i32 - 
        NONCE_SIZE = 
LibSodium.crypto_stream_salsa20_noncebytes.to_i32 
Class Method Summary
Instance Method Summary
- #key_size : Int32
 - #nonce_size : Int32
 - 
        #update(src : Bytes, dst : Bytes) : Bytes
        
          
Xor's src with the cipher output and places in dst.
 
Instance methods inherited from class Sodium::Cipher::Chalsa
  
  
    
      dup
    dup, 
    
  
    
      edible?
    edible?, 
    
  
    
      final
    final, 
    
  
    
      key : Crypto::Secret
    key, 
    
  
    
      key=(key : Bytes | Crypto::Secret) : Crypto::Secret
    key=, 
    
  
    
      key_size : Int32
    key_size, 
    
  
    
      next_u : UInt8
    next_u, 
    
  
    
      nonce : Bytes | Nil
    nonce, 
    
  
    
      nonce=(nonce : Bytes)
    nonce=, 
    
  
    
      nonce? : Bytes | Nil | Nil
    nonce?, 
    
  
    
      nonce_size : Int32
    nonce_size, 
    
  
    
      offset : UInt64
    offset, 
    
  
    
      offset=(offset : UInt64)
    offset=, 
    
  
    
      random_bytes(bytes : Bytes) : Bytes
    random_bytes, 
    
  
    
      random_key
    random_key, 
    
  
    
      random_nonce
    random_nonce, 
    
  
    
      update(src : Bytes, dst : Bytes)update(src : Bytes) : Bytes update
Constructor methods inherited from class Sodium::Cipher::Chalsa
  
  
    
      new(key : Crypto::Secret | Bytes, nonce = nil)
    new
    
  
    
  
    
    
    
  
    
    
    
  
    
    
    
  
Class Method Detail
Instance Method Detail
Xor's src with the cipher output and places in dst.
src and dst may be the same object but should not overlap.