Is the word "law" used in the same way in the following two sentences?

There is a law against kidnapping.

By law, one is not allowed to own a wallaby in New York City.
different meanings