def hash_string():
    string = input("Please Enter Your String: \n")

    # SHA-1 Hash
    hash_objectsha1 = hashlib.sha1(string.encode())
    String_SHA1 = hash_objectsha1.hexdigest()

    # SHA-256 Hash
    hash_objectsha2 = hashlib.sha256(string.encode())
    String_SHA256 = hash_objectsha2.hexdigest()

    # SHA-512 Hash
    hash_objectsha5 = hashlib.sha512(string.encode())
    String_SHA512 = hash_objectsha5.hexdigest()

    # SHA-3 256 Hash
    hash_objectsha3256 = sha3.sha3_256(string.encode())
    String_SHA3256 = hash_objectsha3256.hexdigest()

    # SHA-3 512 Hash
    hash_objectsha3512 = sha3.sha3_512(string.encode())
    String_SHA3512 = hash_objectsha3512.hexdigest()

    print("Your SHA-1 Hash is ", String_SHA1)
    print("\n")
    print("Your SHA-256 Hash is ", String_SHA256)
    print("\n")
    print("Your SHA-512 Hash is ", String_SHA512)
    print("\n")
    print("Your SHA-3 256 Hash is ", String_SHA3256)
    print("\n")
    print("Your SHA-3 512 Hash is ", String_SHA3512)
    print("\n")

    return
Exemplo n.º 2
0
    def __init__(self):
        # Define Supported hashes
        hashes = dict()
        hashes['md2'] = lambda x: self._get_md2_hash(x)
        hashes['md4'] = lambda x: self._get_hashlib_hash('md4', x)
        hashes['md5'] = lambda x: hashlib.md5(x).hexdigest()
        hashes['sha'] = lambda x: self._get_hashlib_hash('sha', x)
        hashes['sha1'] = lambda x: hashlib.sha1(x).hexdigest()
        hashes['sha256'] = lambda x: hashlib.sha256(x).hexdigest()
        hashes['sha224'] = lambda x: hashlib.sha224(x).hexdigest()
        hashes['sha384'] = lambda x: hashlib.sha384(x).hexdigest()
        hashes['sha512'] = lambda x: hashlib.sha512(x).hexdigest()
        hashes['sha3_224'] = lambda x: sha3.sha3_224(x).hexdigest()
        hashes['sha3_256'] = lambda x: sha3.sha3_256(x).hexdigest()
        hashes['sha3_384'] = lambda x: sha3.sha3_384(x).hexdigest()
        hashes['sha3_512'] = lambda x: sha3.sha3_512(x).hexdigest()
        hashes['mmh2'] = lambda x: str(mmhash.get_hash(x))
        hashes['mmh2_unsigned'] = lambda x: str(mmhash.get_unsigned_hash(x))
        hashes['mmh3_32'] = lambda x: str(mmh3.hash(x))
        hashes['mmh3_64_1'] = lambda x: str(mmh3.hash64(x)[0])
        hashes['mmh3_64_2'] = lambda x: str(mmh3.hash64(x)[1])
        hashes['mmh3_128'] = lambda x: str(mmh3.hash128(x))
        hashes['ripemd160'] = lambda x: self._get_hashlib_hash('ripemd160', x)
        hashes['whirlpool'] = lambda x: self._get_hashlib_hash('whirlpool', x)
        hashes['blake2b'] = lambda x: pyblake2.blake2b(x).hexdigest()
        hashes['blake2s'] = lambda x: pyblake2.blake2s(x).hexdigest()
        hashes['crc32'] = lambda x: str(zlib.crc32(x))
        hashes['adler32'] = lambda x: str(zlib.adler32(x))

        self._hashes = hashes
        self.hashes_and_checksums = self._hashes.keys()
        self.supported_hashes = HASHES
Exemplo n.º 3
0
 def test_sha3():
     k = sha3.sha3_512()
     k.update(b"data")
     hd = k.hexdigest()
     do_assert(
         hd,
         '1065aceeded3a5e4412e2187e919bffeadf815f5bd73d37fe00d384fe29f55f08462fdabe1007b993ce5b8119630e7db93101d9425d6e352e22ffe3dcb56b825'
     )
Exemplo n.º 4
0
    def decrypt(self, encrypted_content):

        if not hasattr(self, '_rsa_cipher'):
            raise Exception("No private RSA key loaded")

        encrypted_content_sha = str(
            sha3_512(encrypted_content).hexdigest()).upper()
        content_sha_and_devide_id_string = encrypted_content_sha + self._device_id
        content_sha_and_device_id_sha = sha3_512(
            content_sha_and_devide_id_string.encode(
                'utf-8')).hexdigest().upper()
        content_sha_and_device_id_base64 = base64.b64encode(
            content_sha_and_device_id_sha.encode("utf-8"))
        rsa_encrypt = self._getContentKeyForFile(
            content_sha_and_device_id_base64)
        aes_key, aes_iv = self._RSADecryptContent(rsa_encrypt)
        content = self._AESDecryptContent(aes_key, aes_iv, encrypted_content)
        return content
Exemplo n.º 5
0
def fruit_hash(dataset, mining_hash, nonce):
    seed = [0] * 64
    output = [0] * DGSTSIZE

    val0 = nonce & 0xFFFFFFFF
    val1 = nonce >> 32

    for k in reversed(range(4)):
        seed[k] = val0 & 0xFF
        val0 >>= 8

    for k in reversed(range(4, 8)):
        seed[k] = val1 & 0xFF
        val1 >>= 8

    dgst = [0] * DGSTSIZE

    for k in range(HEADSIZE):
        seed[k + 8] = mining_hash[k]

    sha512_out = sha3_512(bytes(seed)).digest()
    sha512_out = bytes(reversed(sha512_out))

    permute_in = [0] * 32

    for k in range(8):
        for x in range(8):
            sft = x * 8
            val = sha512_out[k * 8 + x] << sft
            permute_in[k] += val

    for k in range(1, 4):
        for x in range(8):
            permute_in[k * 8 + x] = permute_in[x]

    scramble(permute_in, dataset)

    dat_in = [0] * 256

    for k in range(32):
        val = permute_in[k]
        for x in range(8):
            dat_in[k * 8 + x] = val & 0xFF
            val = val >> 8

    for k in range(64):
        temp = dat_in[k * 4]
        dat_in[k * 4] = dat_in[k * 4 + 3]
        dat_in[k * 4 + 3] = temp
        temp = dat_in[k * 4 + 1]
        dat_in[k * 4 + 1] = dat_in[k * 4 + 2]
        dat_in[k * 4 + 2] = temp

    output = sha3_256(bytes(dat_in)).digest()

    return output
Exemplo n.º 6
0
    def password(self, password):
        salt = ""
        numuuid = len(password) / 32
        while numuuid > 0:
            salt += uuid.uuid4().get_hex()
            numuuid = - 1

        sha = sha3.sha3_512(password + salt)
        password = sha.hexdigest()
        self.salt = salt
        self.__password = password
Exemplo n.º 7
0
def SHA3_512_hash_file(filename):
   # make a hash object
   h = sha3.sha3_512()
   # open file for reading in binary mode
   with open(filename,'rb') as file:
       # loop till the end of the file
       chunk = 0
       while chunk != b'':
           # read only 1024 bytes at a time
           chunk = file.read(1024)
           h.update(chunk)
   # return the hex representation of digest
   return h.hexdigest()
Exemplo n.º 8
0
 def authentification(pseudonyme, password):
     try:
         user = Users.get_by_pseudonyme(pseudonyme)
         password = sha3.sha3_512(password + user.salt).hexdigest()
         if password == user.password:
             user.last_login = time.time()
             user.save()
             return True
         else:
             return False
     except Exception as e:
         logging.error(e.message)
         return False
Exemplo n.º 9
0
 def _RSAEncryptContent(self, pubkey_string, aes_concatinated_key,
                        encrypted_content_sha, device_id):
     pem_string = "-----BEGIN PUBLIC KEY-----\n" + pubkey_string + "\n-----END PUBLIC KEY-----\n"
     rsa_public_key = RSA.import_key(pem_string)
     cipher_rsa = PKCS1_OAEP.new(rsa_public_key, hashAlgo=SHA512)
     rsa_encrypted = cipher_rsa.encrypt(aes_concatinated_key)
     rsa_encrypted_base64 = base64.b64encode(rsa_encrypted)
     content_sha_and_devide_id_string = encrypted_content_sha + device_id
     content_sha_and_device_id_sha = sha3_512(
         content_sha_and_devide_id_string.encode(
             'utf-8')).hexdigest().upper()
     content_sha_and_device_id_base64 = base64.b64encode(
         content_sha_and_device_id_sha.encode("utf-8"))
     return content_sha_and_device_id_base64, rsa_encrypted_base64
Exemplo n.º 10
0
 def _AESEncryptContent(self, content):
     aes_key = str.encode(''.join(
         random.SystemRandom().choice(string.ascii_uppercase +
                                      string.ascii_lowercase +
                                      string.digits) for _ in range(32)))
     aes_iv = str.encode(''.join(
         random.SystemRandom().choice(string.ascii_uppercase +
                                      string.ascii_lowercase +
                                      string.digits) for _ in range(16)))
     aes_concatinated_key = aes_key + aes_iv
     aes_cipher = AES.new(aes_key, AES.MODE_CBC, iv=aes_iv)
     encrypted_content = aes_cipher.encrypt(pad(content, AES.block_size))
     encrypted_content_sha = str(
         sha3_512(encrypted_content).hexdigest()).upper()
     return encrypted_content, encrypted_content_sha, aes_concatinated_key
Exemplo n.º 11
0
    def click(self):
        usr = self.usrname.text()
        psw = self.passwd.text()

        pep = random.choice(string.ascii_letters)
        pepas = psw + pep
        print(pepas)
        pepas = sha3.sha3_512(pepas.encode('utf-8')).hexdigest()
        print(pepas)

        qry = "insert into users values('{}','{}',0)"
        cruqry = "CREATE TABLE {} (site VARCHAR(100) NOT NULL,username VARCHAR(100) NOT NULL,password VARCHAR(1024) NOT NULL);"
        mycursor.execute(qry.format(usr, pepas))
        mycursor.execute(cruqry.format(usr))
        mycursor.close()
        mydb.commit()
        self.tableclick(usr)
Exemplo n.º 12
0
def sha3_512(string, salt=None, front=False, back=False, **placeholder):
    """
      Create an SHA3 512 hash from a given string

      > :param string: string to be hashed
      > :return: SHA3 512 hash

      Example
        >>> sha3_512("test")
        9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7b710110c0a678288166e7fbe796883a4f2e9b3ca9f484f521d0ce464345cc1aec96779149c14
    """
    obj = sha3.sha3_512()
    if salt is not None and front is True and not back:
        obj.update(salt + string)
    elif salt is not None and back is True and not front:
        obj.update(string + salt)
    else:
        obj.update(string)
    return obj.hexdigest()
Exemplo n.º 13
0
    def click(self):
        global usr
        usr = self.usrname.text()
        psw = self.passwd.text()
        qry = "Select * from users where username = '******'"
        mycursor.execute(qry.format(usr))
        s = mycursor.fetchall()

        p1 = s[0][1]

        for i in string.ascii_letters:
            w = psw + i

            j = sha3.sha3_512(w.encode('utf-8')).hexdigest()

            if j == p1:

                self.tableclick(usr)

                return usr

        mydb.commit
Exemplo n.º 14
0
 def _sha3_512(x):
     return _sha3.sha3_512(x).digest()
def generate_password_hash(seq):
    return sha3.sha3_512(seq.encode('utf-8')).hexdigest()
Exemplo n.º 16
0
def shaAlgorithms(mode, vectors, number):
    shaTimes = []
    vectores = HashVectorInput(vectors)
    for i in range(len(vectores)):
        if vectores[i] == "million":
            vectores[i] = 'a' * 1000000
        plaintext = bytearray(vectores[i], 'utf-8')
        if mode == 1:
            t = time.perf_counter()
            h = hashlib.sha384(plaintext)
            elapsedTime = time.perf_counter() - t
            shaTimes.append(elapsedTime)
            diggest = h.digest().hex().upper()
            print("Hash SHA384:", diggest)
        elif mode == 2:
            t = time.perf_counter()
            h = hashlib.sha512(plaintext)
            elapsedTime = time.perf_counter() - t
            shaTimes.append(elapsedTime)
            diggest = h.digest().hex().upper()
            print("Hash SHA512:", diggest)
        elif mode == 3:
            t = time.perf_counter()
            h = sha3.sha3_384(plaintext)
            elapsedTime = time.perf_counter() - t
            shaTimes.append(elapsedTime)
            diggest = h.digest().hex().upper()
            print("Hash SHA3_384:", diggest)
        elif mode == 4:
            t = time.perf_counter()
            h = sha3.sha3_512(plaintext)
            elapsedTime = time.perf_counter() - t
            shaTimes.append(elapsedTime)
            diggest = h.digest().hex().upper()
            print("Hash SHA3_512:", diggest)

    for n in range(0, number // 8):
        plaintext = (b'\x00') * n
        if mode == 1:
            t = time.perf_counter()
            h = hashlib.sha384(plaintext)
            elapsedTime = time.perf_counter() - t
            shaTimes.append(elapsedTime)
            diggest = h.digest().hex().upper()
        if mode == 2:
            t = time.perf_counter()
            h = hashlib.sha512(plaintext)
            elapsedTime = time.perf_counter() - t
            shaTimes.append(elapsedTime)
            diggest = h.digest().hex().upper()
        if mode == 3:
            t = time.perf_counter()
            h = sha3.sha3_384(plaintext)
            elapsedTime = time.perf_counter() - t
            shaTimes.append(elapsedTime)
            diggest = h.digest().hex().upper()
        if mode == 4:
            t = time.perf_counter()
            h = sha3.sha3_512(plaintext)
            elapsedTime = time.perf_counter() - t
            shaTimes.append(elapsedTime)
            diggest = h.digest().hex().upper()
    return shaTimes
Exemplo n.º 17
0
def sha3_512(x):
    return hash_words(lambda v: sha3.sha3_512(to_bytes(v)).digest(), 64, x)
Exemplo n.º 18
0
import sys
import sha3

print(sys.version_info)

s = sha3.sha3_512()
data_ = b"data"
s.update(data_)
hexdigest = s.hexdigest()
print('sha3_512')
print(hexdigest)
print()

assert (
    'ceca4daf960c2bbfb4a9edaca9b8137a801b65bae377e0f534ef9141c8684c0fedc1768d1afde9766572846c42b935f61177eaf97d355fa8dc2bca3fecfa754d'
    == hexdigest)

s = sha3.keccak_512()
s.update(data_)
hexdigest = s.hexdigest()
print("keccak_512")
print(hexdigest)
print()

assert (
    '1065aceeded3a5e4412e2187e919bffeadf815f5bd73d37fe00d384fe29f55f08462fdabe1007b993ce5b8119630e7db93101d9425d6e352e22ffe3dcb56b825'
    == hexdigest)

fd = open("../../report_wolfway.pdf", "rb")
s1 = sha3.sha3_512()
s2 = sha3.keccak_512()
Exemplo n.º 19
0
from __future__ import print_function
import sha3, sys

BUF_SIZE = 65536


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


if len(sys.argv) != 2:
    eprint("usage: sha3_512.py (filename)")
    exit(1)

H = sha3.sha3_512()

filename = sys.argv[1]
with open(filename) as f:
    while True:
        data = f.read(BUF_SIZE)
        if not data:
            break
        H.update(data)

print(H.hexdigest())
Exemplo n.º 20
0
    def sha3_512(x): return _sha3.sha3_512(x).digest()
from ethereum.utils import decode_hex
Exemplo n.º 21
0
def sha3_512(x):
    return hash_words(lambda v: sha3.sha3_512(v).digest(), 64, x)
def hash_file():

    file = input("Please Enter The Name of the file you wish to Hash \n")
    print("")

    BLOCKSIZE = 65536
    SHA1_FileHash = hashlib.sha1()
    with open(file, "rb") as afile:
        buf = afile.read(BLOCKSIZE)
        while len(buf) > 0:
            SHA1_FileHash.update(buf)
            buf = afile.read(BLOCKSIZE)

    print("Your SHA-1 Hash is: \n", SHA1_FileHash.hexdigest())
    print("")

    BLOCKSIZE = 65536
    SHA256_FileHash = hashlib.sha256()
    with open(file, "rb") as afile:
        buf = afile.read(BLOCKSIZE)
        while len(buf) > 0:
            SHA256_FileHash.update(buf)
            buf = afile.read(BLOCKSIZE)

    print("Your SHA-256 Hash is : \n", SHA256_FileHash.hexdigest())
    print("")

    BLOCKSIZE = 65536
    SHA512_FileHash = hashlib.sha512()
    with open(file, "rb") as afile:
        buf = afile.read(BLOCKSIZE)
        while len(buf) > 0:
            SHA512_FileHash.update(buf)
            buf = afile.read(BLOCKSIZE)

    print("Your SHA-512 Hash is : \n", SHA512_FileHash.hexdigest())
    print("")

    BLOCKSIZE = 65536
    SHA3256_FileHash = sha3.sha3_256()
    with open(file, "rb") as afile:
        buf = afile.read(BLOCKSIZE)
        while len(buf) > 0:
            SHA3256_FileHash.update(buf)
            buf = afile.read(BLOCKSIZE)

    print("Your SHA-3 256 Hash is : \n", SHA3256_FileHash.hexdigest())
    print("")

    BLOCKSIZE = 65536
    SHA3512_FileHash = sha3.sha3_512()
    with open(file, "rb") as afile:
        buf = afile.read(BLOCKSIZE)
        while len(buf) > 0:
            SHA3512_FileHash.update(buf)
            buf = afile.read(BLOCKSIZE)

    print("Your SHA-3 512 Hash is : \n", SHA3512_FileHash.hexdigest())
    print("")

    return
Exemplo n.º 23
0
def generate_password_hash(seq):
    return sha3.sha3_512(  seq.encode('utf-8') ).hexdigest()
Exemplo n.º 24
0
import sys
import sha3

print(sys.version_info)

s = sha3.sha3_512()
data_ = b"data"
s.update(data_)
hexdigest = s.hexdigest()
print('sha3_512')
print(hexdigest)
print()

assert ('ceca4daf960c2bbfb4a9edaca9b8137a801b65bae377e0f534ef9141c8684c0fedc1768d1afde9766572846c42b935f61177eaf97d355fa8dc2bca3fecfa754d' == hexdigest)

s = sha3.keccak_512()
s.update(data_)
hexdigest = s.hexdigest()
print("keccak_512")
print(hexdigest)
print()

assert ('1065aceeded3a5e4412e2187e919bffeadf815f5bd73d37fe00d384fe29f55f08462fdabe1007b993ce5b8119630e7db93101d9425d6e352e22ffe3dcb56b825' == hexdigest)

fd = open("../../report_wolfway.pdf", "rb")
s1 = sha3.sha3_512()
s2 = sha3.keccak_512()
chunk = True
while chunk != b'':
    chunk = fd.read(2 ** 20)
    s1.update(chunk)
Exemplo n.º 25
0
import sha3

data = 'maydata'
s = sha3.sha3_224(data.encode('utf-8')).hexdigest()
print(s)
data = 'maydata'
s = sha3.sha3_384(data.encode('utf-8')).hexdigest()
print(s)
data = 'maydata'
s = sha3.sha3_512(data.encode('utf-8')).hexdigest()
print(s)
Exemplo n.º 26
0
 def get_hash(self):
     string_to_hash = str(self.index) + str(self.timestamp) + str(self.content) + str(self.previous_hash)
     hash_string = sha3.sha3_512(string_to_hash.encode('utf-8')).hexdigest()
     return hash_string
Exemplo n.º 27
0
    def vivo(self, imx, t, mode):
        print('Steganographic method selected: ' +
              ('SLSB' if mode == 0 else 'LSB'))
        opsx = [[xor, and_, self.imp],
                [xor, self.imp, and_],
                [and_, xor, self.imp],
                [and_, self.imp, xor],
                [self.imp, xor, and_],
                [self.imp, and_, xor]]
        if magic.from_file(imx, mime=True) not in self.PAY_MIME:
            print('ERROR: Use of currently non-supported payload file format detected. ' +
                  'Please use lossless compression image formats only.')
            return 1
        im = img.open(imx)
        print("Mode detected: " + im.mode)
        self.smod = im.mode
        pxs = im.load()
        tf = open(t).read()
        T = bs.ConstBitStream(bytes=tf)
        hx = sha3.sha3_512(tf).hexdigest()
        self.sb = bs.BitArray(bytes=hx).bin
        hfile = open((t + ".sha3" if args.outhash == '' else args.outhash), "w+")
        hfile.write(hx)
        hfile.close()
        r = rnd.Random(self.sb)

        if int(im.width * im.height * 3 * 0.5) < T.len:
            print("ERROR: To few pixels in payload. Availible: " +
                  str(int(im.width * im.height * 3 * 0.5)) +
                  ". Tried to use: " + str(T.len) + ".")
            return 1

        valid_rgba = self.analyze_alpha(pxs, (im.width, im.height))

        rloc = rnd.Random(bs.BitArray(bin=self.sb).uint << 2)
        poi = list()
        while len(poi) < self.MAX_PXS_STORAGE:
            poi.append((rloc.randint(0, im.width - 1), rloc.randint(0, im.height - 1)))
        texlen = str(bin(T.len))[2:]
        tq = list(texlen)

        rsi = rnd.Random(bs.BitArray(bin=self.sb).uint >> 2)
        polis = list()
        while len(polis) < self.MAX_POLIS:
            position = (rsi.randint(0, im.width - 1), rsi.randint(0, im.height - 1))
            if position in polis:
                continue
            polis.append(position)

        q = 0
        for node in poi:
            if q < len(texlen):
                if valid_rgba:
                    lR, lG, lB, lA = pxs[node]
                    if len(texlen) - q > 2:
                        pxs[node] = (lR, lG, int(str(bin(lB))[2:-3] +
                                     tq.pop() + tq.pop() +
                                     tq.pop(), 2), pxs[node][3])
                        q += 3
                        continue
                    if len(texlen) - q > 1:
                        pxs[node] = (lR, lG, int(str(bin(lB))[2:-2] +
                                     tq.pop() + tq.pop(), 2), pxs[node][3])
                        q += 2
                        continue
                    if len(texlen) - q > 0:
                        pxs[node] = (lR, lG, int(str(bin(lB))[2:-1] +
                                     tq.pop(), 2), pxs[node][3])
                        q += 1
                    else:
                        break
                else:
                    lR, lG, lB = pxs[node]
                    if len(texlen) - q > 2:
                        pxs[node] = (lR, lG, int(str(bin(lB))[2:-3] +
                                     tq.pop() + tq.pop() + tq.pop(), 2))
                        q += 3
                        continue
                    if len(texlen) - q > 1:
                        pxs[node] = (lR, lG, int(str(bin(lB))[2:-2] +
                                     tq.pop() + tq.pop(), 2))
                        q += 2
                        continue
                    if len(texlen) - q > 0:
                        pxs[node] = (lR, lG, int(str(bin(lB))[2:-1] +
                                     tq.pop(), 2))
                        q += 1
                    else:
                        break

        plx = list(str(bin(q))[2:])
        while len(plx) < 6:
            plx.insert(0, '0')
        plx = ''.join(plx)
        w = 0
        for poli in polis:
            if valid_rgba:
                pxs[poli] = (pxs[poli][0], pxs[poli][1],
                             int(str(bin(pxs[poli][2]))[2:-3] +
                                 plx[w:w + 3], 2), pxs[poli][3])
            else:
                pxs[poli] = (pxs[poli][0], pxs[poli][1],
                             int(str(bin(pxs[poli][2]))[2:-3] +
                                 plx[w:w + 3], 2))
            w += 3

        end = False
        for i in range(im.width):
            for j in range(im.height):
                if (i, j) in poi:
                    continue
                if (i, j) in polis:
                    continue

                if r.randint(0, 1) != 0:
                    if valid_rgba:
                        R, G, B, A = pxs[i, j]
                    else:
                        R, G, B = pxs[i, j]

                    try:
                        tb = int(T.read('bin:1'))
                    except bs.ReadError:
                        end = True
                        break

                    ops = opsx[[6, 9, 18, 24, 33, 36].index(int(self.next6pack(), 2))]

                    if bool(mode):
                        # LSB
                        pxs[i, j] = (self.trixabit(R, ops[0](R % 2, tb)),
                                     self.trixabit(G, ops[1](R % 2, tb)),
                                     self.trixabit(B, ops[2](R % 2, tb)))
                    else:
                        # G-SLSB
                        pxs[i, j] = (R, G, int(str(bin(B))[2:-3] +
                                     ''.join([str(y(R % 2, tb)) for y in ops]), 2))
            if end:
                break

        pay = imx.split('.')
        if args.outfile == '':
            im.save(pay[-2] + '_.' + pay[-1])
        else:
            im.save(args.outfile)
        print("Your SHA3-512 (Keccak) hash: " + hx)
        print("Done steganographing image [" + imx + "].")

        return 0
Exemplo n.º 28
0
 def validate_proof(self, proof, previous_hash):
     hash_string = (str(previous_hash) + str(proof)).encode('utf-8')
     hash_out = sha3.sha3_512(hash_string).hexdigest()
     n_leading_zeros = len(hash_out) - len(hash_out.lstrip('0'))
     return n_leading_zeros
Exemplo n.º 29
0
 def recreate_hash(self, index, timestamp, content, previous_hash):
     string_to_hash = str(index) + str(timestamp) + str(content) + str(previous_hash)
     hash_string = sha3.sha3_512(string_to_hash.encode('utf-8')).hexdigest()
     return hash_string
Exemplo n.º 30
0
try:
    from Crypto.Hash import keccak

    sha3_256 = lambda x: keccak.new(digest_bits=256, data=x).digest()
    sha3_512 = lambda x: keccak.new(digest_bits=512, data=x)
except:
    import sha3 as _sha3

    sha3_256 = lambda x: _sha3.sha3_256(x).digest()
    sha3_512 = lambda x: _sha3.sha3_512(x).digest()
from rlp.utils import decode_hex, encode_hex
import sys

WORD_BYTES = 4  # bytes in word
DATASET_BYTES_INIT = 2 ** 30  # bytes in dataset at genesis
DATASET_BYTES_GROWTH = 2 ** 23  # growth per epoch (~7 GB per year)
CACHE_BYTES_INIT = 2 ** 24  # Size of the dataset relative to the cache
CACHE_BYTES_GROWTH = 2 ** 17  # Size of the dataset relative to the cache
EPOCH_LENGTH = 30000  # blocks per epoch
MIX_BYTES = 128  # width of mix
HASH_BYTES = 64  # hash length in bytes
DATASET_PARENTS = 256  # number of parents of each dataset element
CACHE_ROUNDS = 3  # number of rounds in cache production
ACCESSES = 64  # number of accesses in hashimoto loop


FNV_PRIME = 0x01000193


def fnv(v1, v2):
    return (v1 * FNV_PRIME ^ v2) % 2 ** 32
Exemplo n.º 31
0
 def digest(self):
     return sha3.sha3_512(self._data).digest()
Exemplo n.º 32
0
try:
    from Crypto.Hash import keccak
    sha3_256 = lambda x: keccak.new(digest_bits=256, data=x).digest()
    sha3_512 = lambda x: keccak.new(digest_bits=512, data=x)
except:
    import sha3 as _sha3
    sha3_256 = lambda x: _sha3.sha3_256(x).digest()
    sha3_512 = lambda x: _sha3.sha3_512(x).digest()
from rlp.utils import decode_hex
from ethereum.utils import encode_hex
import sys

WORD_BYTES = 4  # bytes in word
DATASET_BYTES_INIT = 2**30  # bytes in dataset at genesis
DATASET_BYTES_GROWTH = 2**23  # growth per epoch (~7 GB per year)
CACHE_BYTES_INIT = 2**24  # Size of the dataset relative to the cache
CACHE_BYTES_GROWTH = 2**17  # Size of the dataset relative to the cache
EPOCH_LENGTH = 30000  # blocks per epoch
MIX_BYTES = 128  # width of mix
HASH_BYTES = 64  # hash length in bytes
DATASET_PARENTS = 256  # number of parents of each dataset element
CACHE_ROUNDS = 3  # number of rounds in cache production
ACCESSES = 64  # number of accesses in hashimoto loop

FNV_PRIME = 0x01000193


def fnv(v1, v2):
    return (v1 * FNV_PRIME ^ v2) % 2**32

Exemplo n.º 33
0
def sha512(s):
    hash = sha3.sha3_512()
    hash.update(s)
    return hash.hexdigest()
Exemplo n.º 34
0
def sha3_512(message):
    return sha3.sha3_512(message).digest()
Exemplo n.º 35
0
 def hashAdminPassword(self, password):
     s = sha3.sha3_512()
     password = password.encode('utf-8')
     s.update(password)
     return s.hexdigest()