All posts tagged #rust all posts RSS-feed

Symmetric encryption in Rust

I'm working on a file encryption utility (endec) in Rust. Encrypting and decrypting doesn't need much code, but it took me several hours of fiddling to arrive at the final version, so I thought I'd share the result. The crates I'm using (for the symmetric encryption part) are: aes for encryption secstr to store keys in memory more safely block-modes for block cipher utils So let's get right down to the code: use ::aes::Aes256; use ::block_modes::Cbc; use ::block_modes::BlockMode; use ::block_modes::block_padding::Iso7816;... full post»

Prevent ID-mistakes using Rust types

Recently, I've been interested in designing software to make hard-to-find bugs reveal themselves at compile-time. An idea I've read about (I forgot where) that I found fascinating is the use of a special type for IDs in objects that represent database rows. Problem For example, there may be a User table and a Posts table in the database, with each post belonging to one user. Each of these would be mapped to a class/struct in the programming language. Perhaps each... full post»