Skip to content

Commit

Permalink
v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
0xflotus committed Jan 9, 2023
1 parent a4686d9 commit df7ff8a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions rfc1924/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__version__ = "0.1.8"
__version__ = "0.2.0"
__author__ = "0xflotus"

from .rfc1924 import encode, decode
from .rfc1924 import encode, decode, savings

__all__ = ["encode", "decode"]
__all__ = ["encode", "decode", "savings"]
6 changes: 6 additions & 0 deletions rfc1924/rfc1924.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,9 @@ def decode(encoded_ipv6):
sum = sum + elem * 0x55 ** exp
exp -= 1
return str(IPv6Address(sum))


def savings(ipv6):
encoded = encode(ipv6)
saving = int((1 - len(encoded) / len(ipv6)) * 100)
return f"You saved {saving}%"
4 changes: 3 additions & 1 deletion rfc1924/test_rfc1924.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from rfc1924 import *

assert encode("2345:425:2ca1::567:5673:23b5") == "AN?6(i3Y+yVr74uX@J3P"
assert decode("AN?6(i3Y+yVr74uX@J3P") == "2345:425:2ca1::567:5673:23b5"
assert decode("AN?6(i3Y+yVr74uX@J3P") == "2345:425:2ca1::567:5673:23b5"

print(savings("2345:425:2ca1::567:5673:23b5"))
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name="rfc1924",
version="0.1.8",
version="0.2.0",
description="Implementation of RFC 1924",
long_description=README,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit df7ff8a

Please sign in to comment.