@wuchang/

minirace2

Python

No description

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.9830022266622229","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"ZnJvbSBpdGVydG9vbHMgaW1wb3J0IGN5Y2xlCgpkZWYgc3RyX3RvX2Jpbihfc3RyaW5nKToKICAgICIiIiBUYWtlcyBhIHN0cmluZyBhbmQgb3V0cHV0cyBlYWNoIGNoYXJhY3RlcidzIAogICAgdmFsdWUgYXMgaXRzIGJpbmFyeSBBU0NJSSBjb2RlCiAgICA6cGFyYW0gX3N0cmluZzogc3RyaW5nIHRvIGNvbnZlcnQKICAgIDpyZXR1cm46ICBjb252ZXJ0ZWQgc3RyaW5nCiAgIiIiCiAgICBtID0gIiIKICAgIGZvciBjaGFyIGluIF9zdHJpbmc6CiAgICAgICAgbSArPSAiICB7bnVtOjA4Yn1cbiIuZm9ybWF0KG51bT1vcmQoY2hhcikpCiAgICByZXR1cm4gbQoKZGVmIHN0cl90b19oZXgoX3N0cmluZyk6CiAgICAiIiIgVGFrZXMgYSBzdHJpbmcgYW5kIG91dHB1dHMgZWFjaCBjaGFyYWN0ZXIncyB2YWx1ZSBhcyBpdHMgaGV4YWRlY2ltYWwgQVNDSUkgY29kZQogICAgOnBhcmFtIF9zdHJpbmc6IHN0cmluZyB0byBjb252ZXJ0CiAgICA6cmV0dXJuOiAgY29udmVydGVkIHN0cmluZwogICIiIgogICAgbSA9ICIiCiAgICBmb3IgY2hhciBpbiBfc3RyaW5nOgogICAgICAgIG0gKz0gIns6eH0gIi5mb3JtYXQob3JkKGNoYXIpKQogICAgcmV0dXJuIG0KCmRlZiB2aWdlbmVyZShfc3RyaW5nLCBfa2V5KToKICAgICIiIiBUYWtlcyBhIHN0cmluZyBhbmQgZW5jcnlwdHMgaXQgd2l0aCB0aGUgVmlnZW5lcmUgY2lwaGVyIHVzaW5nIGEgZ2l2ZW4ga2V5CiAgICA6cGFyYW0gX3N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3c3RyaW5nLmxqdXN0KHBhZGRlZF9sZW4sICcuJykKICAgIG0gPSAnJwogICAgZm9yIGkgaW4gcmFuZ2UobnVtX2Jsb2Nrcyk6CiAgICAgICAgbSArPSBwYWRkZWRfc3RyW2k6Om51bV9ibG9ja3NdCiAgICByZXR1cm4gKG0pCgpwcmludChzdHJfdG9faGV4KCJVc2UgU2N5dGFsZSBQZXJpb2QgOCIpICsgIlxuIikKCnByaW50KHNjeXRhbGUoJ0RlY29kZSBUaGUgV29yZCBCZWxvdyBBbmQgVXNlIEl0cyBPcHBvc2l0ZSBDb2xvciBUbyBWaWdlbmVyZSBEZWNvZGUnLCA4KSArICJcbiIpCgpwcmludChzdHJfdG9fYmluKCJCTEFDSyIpKQoKIyBDcmVhdGUgYSBjdXN0b20gYml0Lmx5IFVSTCB3aXRoIGFsbCBDQVBJVEFMIGxldHRlcnMKIyAgIEVuY3J5cHQgd2l0aCBWaWdlbmVyZSBjaXBoZXIgdXNpbmcga2V5IFdISVRFCmJpdGx5ID0gIkNZQkVSUERYIgpzNCA9ICJGaWxsdGhlYmxhbmt3aXRoIiArIGJpdGx5CmtleSA9ICdXSElURScKcHJpbnQodmlnZW5lcmUoczQsIGtleSkpCgpwcmludCgiaHR0cHM6Ly9iaXQubHkvX19fX19fX19fX18iKQo="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from itertools import cycle

def str_to_bin(_string):
    """ Takes a string and outputs each character's 
    value as its binary ASCII code
    :param _string: string to convert
    :return:  converted string
  """
    m = ""
    for char in _string:
        m += "  {num:08b}\n".format(num=ord(char))
    return m

def str_to_hex(_string):
    """ Takes a string and outputs each character's value as its hexadecimal ASCII code
    :param _string: string to convert
    :return:  converted string
  """
    m = ""
    for char in _string:
        m += "{:x} ".format(ord(char))
    return m

def vigenere(_string, _key):
    """ Takes a string and encrypts it with the Vigenere cipher using a given key
    :param _string: string to encrypt
    :param _key: string representing key
    :return:  encrypted string
  """
    alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    plaintext = _string.upper().replace(' ', '')
    cycledkey = cycle(_key)
    m = ''
    for i in range(len(plaintext)):
        m += alpha[(alpha.index(next(cycledkey)) + alpha.index(plaintext[i])) %
                   26]
    return (m + "\n")

def scytale(_string, _n):
    """ Takes a string and encrypts it with the Scytale cipher using a given period n
    :param _string: string to encrypt
    :param _n: integer representing skip length
    :return:  encrypted string
  """
    newstring = _string.replace(' ', '')
    num_blocks = len(newstring) // _n
    if len(newstring) % _n > 0:
        num_blocks = num_blocks + 1
    padded_len = _n * num_blocks
    padded_str = newstring.ljust(padded_len, '.')
    m = ''
    for i in range(num_blocks):
        m += padded_str[i::num_blocks]
    return (m)

print(str_to_hex("Use Scytale Period 8") + "\n")

print(scytale('Decode The Word Below And Use Its Opposite Color To Vigenere Decode', 8) + "\n")

print(str_to_bin("BLACK"))

# Create a custom bit.ly URL with all CAPITAL letters
#   Encrypt with Vigenere cipher using key WHITE
bitly = "CYBERPDX"
s4 = "Filltheblankwith" + bitly
key = 'WHITE'
print(vigenere(s4, key))

print("https://bit.ly/___________")