1
0
mirror of synced 2024-11-13 17:40:47 +01:00
bemaniutils/bemani/utils/cardconvert.py
2024-01-02 02:46:24 +00:00

27 lines
746 B
Python

import argparse
from bemani.common import CardCipher, CardCipherException
def main() -> None:
parser = argparse.ArgumentParser(description="A utility to convert between card IDs and back-of-card characters.")
parser.add_argument(
"number",
help="card ID or back-of-card characters to convert.",
type=str,
)
args = parser.parse_args()
try:
print(CardCipher.decode(args.number))
except CardCipherException:
try:
back = CardCipher.encode(args.number)
print(" ".join([back[i : (i + 4)] for i in range(0, len(back), 4)]))
except CardCipherException:
print("Bad card ID or back-of-card characters!")
if __name__ == "__main__":
main()