Skip to content

Commit 59b4ae1

Browse files
committed
Fix bug for charSet2
count can be 256, which won’t fit in an UInt8
1 parent 43f425e commit 59b4ae1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/Random.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public class Random {
128128
guard needed <= bytes.count else { throw EntropyStringError.tooFewBytes }
129129

130130
let chunks = count / Int(charSet.charsPerChunk)
131-
let partials = UInt8(count) % charSet.charsPerChunk
131+
let partials = UInt8(count % Int(charSet.charsPerChunk))
132132

133133
var string = ""
134134
for chunk in 0 ..< chunks {

0 commit comments

Comments
 (0)