add toBytes (#14)

This commit is contained in:
Jacek Sieka 2019-12-10 15:39:57 +01:00 committed by Mamy Ratsimbazafy
parent 1c4293b3e7
commit cf4df3dc50
1 changed files with 8 additions and 2 deletions

View File

@ -123,3 +123,9 @@ func toHex*[N: static[int]](ba: array[N, byte]): string {.inline.} =
## Output is in lowercase
## No "endianness" reordering is done.
toHexAux(ba)
func toBytes*(s: string): seq[byte] =
## Convert a string to the corresponding byte sequence - since strings in
## nim essentially are byte sequences without any particular encoding, this
## is almost a noop
cast[seq[byte]](s)