Skip to content
DeepForgeby svx
All problems
MediumInformation Theoryinfo-173

Key Space Bits

Problem

Return the size of a keyspace in bits: log2(number_of_keys). This is the security level of a uniformly random key from that space.

Hint

A one-key space has zero bits of security.

Test cases

case 1
in: [256]
expected: 8
case 2
in: [1024]
expected: 10
case 3
in: [1]
expected: 0
case 4
in: [208827064576]
expected: 37.603517745128734
Starter codePython
import math
def keyspace_bits(keyspace):
    # Your code here
    pass

4 test cases · run your code against them in the editor