Esempio n. 1
0
def main():
    m = hashlib.sha256()
    while True:
        chunk = stdin.read(1024)
        if not chunk:
            break
        m.update(chunk)
    stdout.write(m.hexdigest().encode() + b'\n')
Esempio n. 2
0
def main():
    out = six.BytesIO()
    shutil.copyfileobj(stdin, out)
    md5 = hashlib.md5()
    md5.update(out.getvalue())
    stdout.write(out.getvalue())
    stdout.flush()
    stderr.write(md5.hexdigest().encode() + b'\n')
    stderr.flush()
Esempio n. 3
0
def main():
    args = parse_argv()
    remaining = args.count
    while remaining:
        chunk = stdin.read(1024)
        if not chunk:
            break
        output = chunk[:remaining] if remaining < len(chunk) else chunk
        remaining -= len(output)
        stdout.write(output)
Esempio n. 4
0
def flush(buf):
    stdout.write(b''.join(buf + [b'\n']))
Esempio n. 5
0
def main():
    args = parse_argv()
    data = args.data.encode('utf8')
    for _ in range(args.count):
        stdout.write(data)