Category : implementation

I have written a stack in python,and would like to remove all none implemented method that has be inherited from the deque class so that a stack instance may never call them. from collections import deque class Stack(deque): def __init__(self, iterable) -> None: self.iterable=iterable super().__init__(iterable=self.iterable) self.count = len(self.iterable) def clear(self): self.count = 0 return super().clear() ..

Read more

import hashlib def xor(x, y): return bytes(x[i] ^ y[i] for i in range(min(len(x), len(y)))) def hmac_sha1(key_K, data): if len(key_K) > 64: raise ValueError(‘The key must be <= 64 bytes in length’) padded_K = key_K + b’x00′ * (64 – len(key_K)) ipad = b’x36′ * 64 opad = b’x5c’ * 64 h_inner = hashlib.sha1(xor(padded_K, ipad)) h_inner.update(data) ..

Read more