cryptography

Time complexity of MD5

爷,独闯天下 提交于 2020-12-30 09:55:37
问题 What is the time complexity of the MD5 algorithm? I couldn't find a definitive answer online. I think the complexity is O(n) but I'm not really sure. 回答1: O(n) as mentioned by DuBuisson and osgx in the comments. 来源: https://stackoverflow.com/questions/43625569/time-complexity-of-md5

Javascript equivalent to Java SHA1PRNG

那年仲夏 提交于 2020-12-26 12:13:28
问题 I have a Java Application that uses "AES-128 bits/ECB/PKCS5Padding" (java8 linux/window), the code is quite simple KeyGenerator keygen = KeyGenerator.getInstance("AES"); SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG"); secureRandom.setSeed(seed.getBytes()); keygen.init(128, secureRandom); ... Because I can't find the javascript equivalent to SHA1PRNG algorithm I can't decrypt the text using js code. But after reading Decrypt AES/CBC/PKCS5Padding with CryptoJS and with some

《C# 爬虫 破境之道》:第二境 爬虫应用 — 第一节:HTTP协议数据采集

旧城冷巷雨未停 提交于 2020-12-19 06:20:06
首先欢迎您来到本书的第二境,本境,我们将全力打造一个实际生产环境可用的爬虫应用了。虽然只是刚开始,虽然路漫漫其修远,不过还是有点小鸡冻:P 本境打算针对几大派生类做进一步深耕,包括与应用的结合、对比它们之间的区别、综合共性、封装。One-By-One。 System.IO.Packaging.PackWebRequest System.Net.FileWebRequest System.Net.FtpWebRequest System.Net.HttpWebRequest 第一节,我们先来说说最重要、最常用的HttpWebRequest。撸码的细节就不说了,看不懂的童鞋可以去看看第一境就明白了:) 示例解决方案分为两个项目,一个应用程序(控制台),一个类库(取了个高大上的名字:System.Crawler)。所以,在应用程序中需要引用System.Crawler。应用程序可以是控制台、窗体项目、Win服务、WPF等,随便整,随你随地大小便…… 先展示一下应用程序的最终的效果,然后我们再逐步引出类库的实现。 [Code 2.1.1] 1 using System.Crawler; 2 3 { 4 #region 以GET方式请求数据 5 var ant = new WorkerAnt 6 { 7 WorkerId = ( uint )Math.Abs(DateTime.Now

Encrypt a big file that does not fit in RAM with AES-GCM

冷暖自知 提交于 2020-12-14 06:30:31
问题 This code works for a file myfile which fits in RAM: import Crypto.Random, Crypto.Cipher.AES # pip install pycryptodome nonce = Crypto.Random.new().read(16) key = Crypto.Random.new().read(16) # in reality, use a key derivation function, etc. ouf of topic here cipher = Crypto.Cipher.AES.new(key, Crypto.Cipher.AES.MODE_GCM, nonce=nonce) out = io.BytesIO() with open('myfile', 'rb') as g: s = g.read() ciphertext, tag = cipher.encrypt_and_digest(s) out.write(nonce) out.write(ciphertext) out.write

Certificate revocation with python cryptography

假装没事ソ 提交于 2020-12-13 03:08:21
问题 I'm trying to make a certificate revocation list using the python cryptography library. So far I haven't been successful. I am able to generate the certificates with the same library. The certificates work because I am able to use them for a connection with MQTT. The problem is when I try to revoke one of the certificates. Then no connection works and I receive an error: It would be nice if someone tell me what I am doing wrong. Thanks in advance. This is my code: # THIS CERTIFICATE I WANT TO

Is there a ARM processor support on-chip hardware random number generator?

梦想与她 提交于 2020-12-08 08:00:30
问题 Intel supports RDRAND (also known as Intel secure key) instruction for returning random numbers. And it's available in Ivy Bridge processors. I wonder, is there any ARM processor featuring instructions for on-chip hw random number generator functionally similar to RDRAND? And I have an additional question. In the Linux kernel (version 3.10), there are driver sources for hw random number generators in /linux/drivers/char/hw_random . (http://lxr.free-electrons.com/source/drivers/char/hw_random/

What kind of padding should AES use?

心不动则不痛 提交于 2020-12-03 07:42:09
问题 I have implemented the AES encryption (homework), but I stumble upon the problem of padding the messages. If my messages are arrays of bytes as such: public byte[] encrypt(byte[] message) { int size = (int) Math.ceil(message.length / 16.0); byte[] result = new byte[size * 16]; for (int i = 0; i < size; i++) { if ((i+1) * 16 > message.length){ //padding here???? } else { byte[] block = Arrays.copyOfRange(message, i * 16, (i + 1) * 16); byte[] encryptedBlock = encryptBlock(block); System

RSA decryption of AES Session key fails with 'AttributeError: 'bytes' object has no attribute 'n'

[亡魂溺海] 提交于 2020-12-01 11:07:37
问题 I'm working on implementing a public key encryption from PyCryptodome on Python 3.6. When I try to create a symmetric encryption key and encrypt/decrypt variables, it all works fine. But the minute I introduce RSA (and PKCS1_OAEP), it all goes down the tubes - the session_key encrypts fine but when I try and decrypt it, I get the following error: Traceback (most recent call last): File "enctest.py", line 109, in <module> deckey = decrypt_val(enckey) File "enctest.py", line 77, in decrypt_val