apple / swift-crypto

Open-source implementation of a substantial portion of the API of Apple CryptoKit suitable for use on Linux platforms.
https://apple.github.io/swift-crypto
Apache License 2.0
1.47k stars 166 forks source link

Fix broken `DataProtocol.hexString` test utility #230

Closed simonjbeaumont closed 6 months ago

simonjbeaumont commented 6 months ago

Motivation:

The test code has utility extensions for converting bytes to and from hex strings. However, the hexString computed property only returned half the bytes it should because it uses Array.init(unsafeUnitializedCapacity:_:) and set the array count to the number of bytes, rather than double the number of bytes, which is the required number of hexadecimal characters in the resulting string.

Modifications:

Result:

DataProtocol.hexString: String now returns a hex string for all the bytes.