Skip to content

Expose methods for hex encoding bytes

Pre-release
Pre-release
Compare
Choose a tag to compare
@tanner0101 tanner0101 released this 17 Feb 22:17
7bd5d33

Exposes methods for generating hex-encoded strings from a collection of bytes (#2189, fixes #2187).

import Vapor

let bytes: [UInt8] = ...
print(bytes.hexEncodedString()) // Hex-encoded w/ lowercase characters
print(bytes.hexEncodedString(uppercase: true)) // Hex-encoded w/ uppercase characters

A concise hex method has also been added to match the similar base64 method which already exists.

print(bytes.hex) // Hex-encoded string (lowercase)