예제 #1
0
파일: _utils.py 프로젝트: HengeSense/vesper
def shaDigest(filepath):
    BUF = 8192
    sha = sha1()
    shaFile = file(filepath, 'rb', BUF)
    for line in iter(lambda: shaFile.read(BUF), ""):
        sha.update(line)
    shaFile.close()
    return b2a_base64(sha.digest())[:-1]
예제 #2
0
def shaDigest(filepath):
    BUF = 8192
    sha = sha1()
    shaFile = file(filepath, 'rb', BUF)
    for line in iter(lambda: shaFile.read(BUF), ""):
        sha.update(line)
    shaFile.close()
    return b2a_base64(sha.digest())[:-1]
예제 #3
0
def create_files(sha, basedir, base_names, size):
    global total_name_bytes
    global counter

    while total_name_bytes < size:
        s = str(counter)
        counter += 1

        sha.update(s)
        s = sha.hexdigest() * 6
        total_name_bytes += len(s)
        base_names[s] = 0
        fp = file(os.path.join(basedir, s + ".0"), 'w')
        fp.close()
        if counter % 10000 == 0:
            print "%d files %d MB total" % (counter,
                                            total_name_bytes / (1024 * 1024))
예제 #4
0
def make_secret(password):
    """
    Encodes the given password as a base64 SSHA hash+salt buffer
    """
    salt = os.urandom(4)

    # hash the password and append the salt
    sha = hashlib.sha1(password)
    sha.update(salt)

    # create a base64 encoded string of the concatenated digest + salt
    digest_salt_b64 = '{}{}'.format(sha.digest(), salt).encode('base64').strip()

    # now tag the digest above with the {SSHA} tag
    tagged_digest_salt = '{{SSHA}}{}'.format(digest_salt_b64)

    return tagged_digest_salt
예제 #5
0
#
# Once you see all three ready lines, turn off power.  Don't use the
# power button on the front of the machine, either pull the plug, use
# the power switch on the back of the machine, or use an external controller
#
# Written by Chris Mason <*****@*****.**>

import sys, os, sha, random, mmap
from optparse import OptionParser

total_name_bytes = 0
counter = 0
errors = 0
sha = sha.new()
salt = file("/dev/urandom").read(256)
sha.update(salt)
VERSION = "0.2"

def read_files(basedir, base_names):
    global total_name_bytes
    global counter
    global errors

    for x in os.listdir(basedir):
        total_name_bytes += len(x)
        counter += 1

        full = os.path.join(basedir, x)
        if not full.endswith(".0") and not full.endswith(".1"):
            continue
        num = int(x[-1])
예제 #6
0
파일: _utils.py 프로젝트: HengeSense/vesper
def shaDigestString(line):
    sha = sha1()
    sha.update(line)
    return b2a_base64(sha.digest())[:-1]
예제 #7
0
def iter_sha1(iter):
    sha = hashlib.sha1()
    for name in iter:
        sha.update(name)
    return sha.hexdigest()
예제 #8
0
def shaDigestString(line):
    sha = sha1()
    sha.update(line)
    return b2a_base64(sha.digest())[:-1]