Reading Books To Learn Tech
Tags: read, learn
Published: 2022-06-23 19:15:12

## Reading Tech Books In Public

I'm beginning a project named The Build In Public Developer -- with an associated web site (https://buildip.dev).
This project will help illuminate that challenges which are too rarely spoken of and which are often hidden from new developers.

I plan on talking about all the challenges I face as I develop complete applications or attempt to learn new technology.  

I have 30 Years of IT (Information Technology) experience which includes more than 20 years of Professional Software Development.

###Learning To Read Tech Documentation

I remember learning to read the cryptic Windows API documentation to learn how to create a new window.
```
void CreateWindowA(
  [in, optional]  lpClassName,
  [in, optional]  lpWindowName,
  [in]            dwStyle,
  [in]            x,
  [in]            y,
  [in]            nWidth,
  [in]            nHeight,
  [in, optional]  hWndParent,
  [in, optional]  hMenu,
  [in, optional]  hInstance,
  [in, optional]  lpParam
);
```

So I've been around the block and seen a few things, but I still stumble a lot when reading and learning new concepts.

I'm reading the book, Real-World Cryptography (Manning Publishers <a href="https://www.amazon.com/Real-World-Cryptography-David-Wong-ebook/dp/B09FR9YJWD?keywords=real-world+cryptography&qid=1656007873&sprefix=real-world%2Caps%2C69&sr=8-1&linkCode=li3&tag=radink-20&linkId=57a9d9af7ed70da3a377ab61ff12d13c&language=en_US&ref_=as_li_ss_il" target="_blank"><img border="0" src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=B09FR9YJWD&Format=_SL250_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=radink-20&language=en_US" ></a><img src="https://ir-na.amazon-adsystem.com/e/ir?t=radink-20&language=en_US&l=li3&o=1&a=B09FR9YJWD" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> , by David Wong.  It is an interesting book but it misses quite a bit.

###Author Leaves Me Behind A Lot

This book is really interesting & I'm going to keep going but I keep stumbling as the author explains a concept so quickly that I have no idea what he is talking about.  I'm still thinking about his last sentence and he is moving on to the next concept.

###Sample Code

At one point in the third chapter the author provides sample code which consist of two functions written in Rust. The first function is supposed to generate a MAC (Message Authentication Code) and I decide to try the code out.

I open up my trusty code editor (Visual Studio Code, of course) and type the code in.

Yes, I decide to actually type the code because you learn more by doing the work.

Here's what the author provides :
```
use sha2::Sha256;
use hmac::{Hmac, Mac};

fn send_message(key: &[u8], message: &[u8]) -> Vec{
    let mut mac = Hmac::::new(key.into());
    mac.update(message);
    mac.finalize().into_bytes().to_vec()
}
```

### Missing Parts

However, there is a lot of missing parts to this.

#### Main Function

Of course if you want to try this out you need a main function where you'll call the send_message() function.

#### Missing Crates (References to Libraries)

You are also missing the two required crates (which you'll have to add to your project's cargo.toml.

It takes me a bit (I'm new to Rust) but I finally find the crates & remember the format required to add them to the toml file.
```
[dependencies]
sha2 = "0.10.2"
hmac = "0.12.1"
```

It builds at this point, but now the problem is that I don't know how to actually call the function.  I'm not sure what the input is supposed to be formatted.

### Trying It

So I make some guesses to get it working.

I call it like the following:

```send_message(&[59,64,38,99], &[33,55,65,68]);```

I have to really stare at the error message I get from the Rust compiler:

```
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `4`,
right: `64`', C:\Users\1rade\.cargo\registry\src\github.com-1ecc6299db9ec823\generic-array-0.14.5\src\lib.rs:559:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

Finally, I notice the one clue:  the left is four bytes (this is probably the first argument).

Then I try another thing. I decide to try to convert the input from a string to bytes to make the input easier.

```send_message(b"1234567", b"abcdef");```

I compile and see the following:
```
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `7`,
right: `64`',
```

So, yes, that confirms that I can convert a string to bytes & pass it in and that the left 7 value is the number of bytes.  However, it still fails.  But my next guess is that is because the left is only 7 and it wants 64 bytes.  I create a 64 byte string on the left to pass in and try it again.

```
send_message(
  b"garbage here padd it out for 64 bytes see what happens 123456789",
   b"extra garbage")
```
It worked!


### My Point: Technical Authors Have To Provide Details
Technical authors have to provide all the details of what they are explaining but there is often a lot of missing info.
### Don't Give Up, You're Not Alone
Don't give up and don't feel like you are the only one this happens to.  It's happening to all of us out here.